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

Allow to override min_size via command-line argument #114

Merged
merged 8 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 10 additions & 1 deletion src/main/java/com/glencoesoftware/bioformats2raw/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@ public class Converter implements Callable<Void> {
)
private volatile boolean reuseExistingResolutions = false;

@Option(
names = "--min-size",
description = "Minimum size of the largest XY dimension in the" +
"smallest resolution, when calculating the number of resolutions" +
" generate."
)
private volatile int minSize = MIN_SIZE;


/** Scaling implementation that will be used during downsampling. */
private volatile IImageScaler scaler = new SimpleImageScaler();

Expand Down Expand Up @@ -1113,7 +1122,7 @@ public void saveResolutions(int series)
else {
int width = workingReader.getSizeX();
int height = workingReader.getSizeY();
while (width > MIN_SIZE || height > MIN_SIZE) {
while (width > minSize || height > minSize) {
resolutions++;
width /= PYRAMID_SCALE;
height /= PYRAMID_SCALE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,29 @@ public void testChunkSizeToBig() throws Exception {
}
}

/**
* Convert an image with the --min-size option.
*/
@Test
public void testMinSizeOption() throws Exception {
input = fake();
assertTool("--min-size", "32");

ZarrGroup z = ZarrGroup.open(output.resolve("0").toString());
List<Map<String, Object>> multiscales = (List<Map<String, Object>>)
z.getAttributes().get("multiscales");

Map<String, Object> multiscale = multiscales.get(0);
List<Map<String, Object>> datasets =
(List<Map<String, Object>>) multiscale.get("datasets");

String lastPath = (String) datasets.get(datasets.size() - 1).get("path");
ZarrArray lastArray = z.openArray(lastPath);

assert lastArray.getShape()[0] < 32;
assert lastArray.getShape()[1] < 32;
sbesson marked this conversation as resolved.
Show resolved Hide resolved
}

private void checkPlateGroupLayout(Path root, int rowCount, int colCount,
int fieldCount, int x, int y)
throws IOException
Expand Down