Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #47

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/main/java/qupath/ext/wsinfer/TileLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,26 @@ private TileBatch nextBatch() {
} else {
// Handle normal case of within-bounds coordinates
img = server.readRegion(downsample, x, y, width, height);
if (resizeWidth > 0 && resizeHeight > 0)
img = BufferedImageTools.resize(img, resizeWidth, resizeHeight, true);
}
if (resizeWidth > 0 && resizeHeight > 0) {
// Using OpenCV is much faster tha BufferedImageTools/ImageJ,
// but using BufferedImageTools (and ImageJ) seems to give more similar results to WSInfer Python.
// For example, using the Python WSInfer 0.5.0 output for the image at
// https://github.com/qupath/qupath-docs/issues/89 (30619 tiles):
// BufferedImageTools Tumor prob Mean Absolute Difference: 0.0026328298250342763
// OpenCV Tumor prob Mean Absolute Difference: 0.07625036735485102
//
// Note: If we activate this, then we should handle the if/else above separately to avoid
// regenerating a Mat unnecessarily.
// var mat = OpenCVTools.imageToMat(img);
// var size = new Size(resizeWidth, resizeHeight);
// opencv_imgproc.resize(mat, mat, size, 0, 0, opencv_imgproc.INTER_LINEAR);
// img = OpenCVTools.matToBufferedImage(mat);
// size.close();
// mat.close();
img = BufferedImageTools.resize(img, resizeWidth, resizeHeight, true);
}

Image input = BufferedImageFactory.getInstance().fromImage(img);
pathObjectBatch.add(pathObject);
inputs.add(input);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/qupath/ext/wsinfer/ui/WSInferController.java
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,10 @@ private void selectedPathObjectChanged(PathObject pathObjectSelected, PathObject
}

private void updateSelectedObjectCounts() {
if (!Platform.isFxApplicationThread()) {
Platform.runLater(this::updateSelectedObjectCounts);
return;
}
var hierarchy = hierarchyProperty.getValue();
if (hierarchy == null) {
numSelectedAnnotations.set(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</Button>
</children>
</HBox>
<Label id="labelWarning" fx:id="labelMessage" prefHeight="30.0" styleClass="error-message" text="%ui.error.no-selection" VBox.vgrow="ALWAYS" />
<Label id="labelWarning" fx:id="labelMessage" styleClass="error-message" text="%ui.error.no-selection" VBox.vgrow="ALWAYS" />
<styleClass>
<String fx:value="standard-spacing" />
<String fx:value="standard-padding" />
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/qupath/ext/wsinfer/ui/wsinferstyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}

.standard-padding {
-fx-padding: 4;
-fx-padding: 2;
}

/*download button*/
Expand Down