Skip to content

Commit

Permalink
Merge pull request #60 from petebankhead/pixel-size
Browse files Browse the repository at this point in the history
Fix pixel size/downsample inconsistency
  • Loading branch information
petebankhead authored Sep 4, 2024
2 parents 2e6352f + 0bb8c1c commit 08a3ee9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/main/java/qupath/ext/instanseg/core/DetectionMeasurer.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,19 @@ public static class Builder {
.filter(m -> m != ObjectMeasurements.Measurements.VARIANCE) // Skip variance - we have standard deviation
.toList();
private Collection<ObjectMeasurements.ShapeFeatures> shapeFeatures = Arrays.asList(ObjectMeasurements.ShapeFeatures.values());
private double pixelSize;
private double downsample;

/**
* Set the pixel size that measurements should be made at.
* @param pixelSize The pixel size that detections/annotations/etc were made at.
* Set the downsample that the measurer should use.
* The measurer is assumed to be short-lived and used for a single image, and so doesn't need to maintain a
* value related to pixel size. Therefore, it takes an explicit downsample to avoid any risk that the
* pixel-size-to-downsample calculation here wouldn't match that done during detection.
*
* @param downsample The downsample that detections/annotations/etc should be made at.
* @return A modified builder.
*/
public Builder pixelSize(double pixelSize) {
this.pixelSize = pixelSize;
public Builder downsample(double downsample) {
this.downsample = downsample;
return this;
}

Expand Down Expand Up @@ -140,7 +144,7 @@ public Builder shapeFeatures(Collection<ObjectMeasurements.ShapeFeatures> shapeF
* @return An immutable detection measurer.
*/
public DetectionMeasurer build() {
return new DetectionMeasurer(compartments, measurements, shapeFeatures, pixelSize);
return new DetectionMeasurer(compartments, measurements, shapeFeatures, downsample);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/qupath/ext/instanseg/core/InstanSeg.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static Builder builder() {
public void makeMeasurements(ImageData<BufferedImage> imageData, Collection<? extends PathObject> detections) {
double downsample = model.getPreferredDownsample(imageData.getServer().getPixelCalibration());
DetectionMeasurer.builder()
.pixelSize(downsample)
.downsample(downsample)
.build()
.makeMeasurements(imageData, detections);
}
Expand Down

0 comments on commit 08a3ee9

Please sign in to comment.