Skip to content

Commit

Permalink
add support for 16-bit output to RenderTilesClient
Browse files Browse the repository at this point in the history
  • Loading branch information
trautmane committed Oct 31, 2024
1 parent 6f4b19e commit e0a11f0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ public static BufferedImage targetToShortImage(final ImageProcessorWithMasks ren
return new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_USHORT_GRAY);
};

private static final Renderer.ProcessorWithMasksConverter CONVERTER =
public static final Renderer.ProcessorWithMasksConverter CONVERTER =
(renderParameters, renderedImageProcessorWithMasks) -> targetToShortImage(renderedImageProcessorWithMasks);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.janelia.alignment.ImageAndMask;
import org.janelia.alignment.RenderParameters;
import org.janelia.alignment.Renderer;
import org.janelia.alignment.ShortRenderer;
import org.janelia.alignment.Utils;
import org.janelia.alignment.loader.DynamicMaskLoader;
import org.janelia.alignment.loader.ImageLoader;
Expand Down Expand Up @@ -58,6 +59,10 @@
*/
public class RenderTilesClient {

public enum RenderType {
EIGHT_BIT, SIXTEEN_BIT, ARGB
}

public static class Parameters extends CommandLineParameters {

@ParametersDelegate
Expand Down Expand Up @@ -101,9 +106,9 @@ public static class Parameters extends CommandLineParameters {
public boolean doFilter = false;

@Parameter(
names = "--render8Bit",
description = "Render the tiles as 8-bit grayscale images")
public boolean render8Bit = true;
names = "--renderType",
description = "How the tiles should be rendered")
public RenderType renderType = RenderType.EIGHT_BIT;

@Parameter(
names = "--filterListName",
Expand Down Expand Up @@ -322,7 +327,7 @@ private void collectTileInfo()
}
}

if (tileIds.size() == 0) {
if (tileIds.isEmpty()) {
throw new IllegalArgumentException("There are no tiles to render!");
}

Expand Down Expand Up @@ -403,14 +408,17 @@ private void renderTile(final String tileId)
if (clientParameters.excludeMask) {
// skip conversion step if we don't need to worry about mask
bufferedImage = imageProcessorWithMasks.ip.getBufferedImage();
} else if (clientParameters.renderType == RenderType.EIGHT_BIT) {
bufferedImage = ByteRenderer.CONVERTER.convertProcessorWithMasksToImage(renderParameters,
imageProcessorWithMasks);
} else if (clientParameters.renderType == RenderType.SIXTEEN_BIT) {
bufferedImage = ShortRenderer.CONVERTER.convertProcessorWithMasksToImage(renderParameters,
imageProcessorWithMasks);
} else if (clientParameters.renderType == RenderType.ARGB) {
bufferedImage = ArgbRenderer.CONVERTER.convertProcessorWithMasksToImage(renderParameters,
imageProcessorWithMasks);
} else {
if (clientParameters.render8Bit) {
bufferedImage = ByteRenderer.CONVERTER.convertProcessorWithMasksToImage(renderParameters,
imageProcessorWithMasks);
} else {
bufferedImage = ArgbRenderer.CONVERTER.convertProcessorWithMasksToImage(renderParameters,
imageProcessorWithMasks);
}
throw new IllegalArgumentException("unsupported render type: " + clientParameters.renderType);
}

Utils.saveImage(bufferedImage,
Expand Down Expand Up @@ -493,7 +501,7 @@ private void renderTile(final String tileId)

if ((translateX != 0.0) || (translateY != 0.0)) {
final String translateDataString = translateX + " " + translateY;
LOG.info("renderTile: translating hacked tile by " + translateDataString);
LOG.info("renderTile: translating hacked tile by {}", translateDataString);
final TransformSpec translateToPreHackLocationSpec =
new LeafTransformSpec(TranslationModel2D.class.getName(), translateDataString);
resolvedTiles.addTransformSpecToTile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,21 @@ public void testParameterParsing() throws Exception {
public static void main(final String[] args) {
try {
final String[] testArgs = {
"--baseDataUrl", "http://renderer-dev.int.janelia.org:8080/render-ws/v1",
// "--owner", "Z0720_07m_VNC",
// "--project", "Sec07",
// "--stack", "v4_acquire_trimmed_align",
// "--rootDirectory", "/nrs/flyem/render/tiles",
// "--z", "1817",
// "--hackStack", "v4_acquire_trimmed_align_hack",
// "--hackTransformCount", "1",

// "--owner", "Z0720_07m_VNC",
// "--project", "Sec19",
// "--stack", "v7_acquire_trimmed_align_straightened",
// "--rootDirectory", "/nrs/flyem/render/tiles",
// "--z", "7547",
// "--hackStack", "v7_acquire_trimmed_align_straightened_hack",
// "--hackTransformCount", "1",
// "--completeHackStack"

"--baseDataUrl", "http://em-services-1.int.janelia.org:8080/render-ws/v1",
"--owner", "fibsem",
"--project", "Z0422_17_VNC_1",
"--stack", "v4_acquire_trimmed_align",
"--rootDirectory", "/nrs/fibsem/render/tiles_destreak",
"--project", "jrc_celegans_20240819",
"--stack", "v3_acquire_align_16bit",
"--rootDirectory", " /nrs/fibsem/data/jrc_celegans_20240819/tiles_destreak",
"--runTimestamp", "20241031_150000",
"--scale", "1.0",
"--format", "png",
"--excludeMask",
"--excludeAllTransforms",
"--filterListName", "Z0422_17_VNC_1",
"--tileIdPattern", ".*0-.-2.*",
"--hackStack", "v4_acquire_trimmed_align_destreak_test_b",
"--filterListName", "jrc_celegans_20240819-destreak-16bit",
"--hackStack", "v3_acquire_align_16bit_destreak_test",
"--renderType", "SIXTEEN_BIT",
"--completeHackStack",
"--z", "28132", "28133",
"--z", "4444.0"
};

RenderTilesClient.main(testArgs);
Expand Down

0 comments on commit e0a11f0

Please sign in to comment.