@Test public void testClipForMontagePair() { final int fullWidth = 3840; final int fullHeight = 3840; final int clipWidth = 20; final int clipHeight = 10; final double leftXOffset = fullWidth - clipWidth; final double topYOffset = fullHeight - clipHeight; final Object[][] testData = { { MontageRelativePosition.TOP, fullWidth, clipHeight, 0.0, topYOffset }, { MontageRelativePosition.BOTTOM, fullWidth, clipHeight, 0.0, 0.0 }, { MontageRelativePosition.LEFT, clipWidth, fullHeight, leftXOffset, 0.0 }, { MontageRelativePosition.RIGHT, clipWidth, fullHeight, 0.0, 0.0 } }; for (final Object[] data : testData) { final RenderParameters parameters = new RenderParameters("renderer-test.json", 0, 0, fullWidth, fullHeight, 1.0); final CanvasId canvasId = new CanvasId("groupA", "tileB", (MontageRelativePosition) data[0]); canvasId.setClipOffsets(fullWidth, fullHeight, clipWidth, clipHeight); parameters.clipForMontagePair(canvasId, clipWidth, clipHeight); Assert.assertEquals("invalid clipped width for " + canvasId, data[1], parameters.getWidth()); Assert.assertEquals("invalid clipped height for " + canvasId, data[2], parameters.getHeight()); Assert.assertEquals("invalid x for " + canvasId, (Double) data[3], parameters.getX(), 0.001); Assert.assertEquals("invalid y for " + canvasId, (Double) data[4], parameters.getY(), 0.001); } }
public void clipForMontagePair(final CanvasId canvasId, final Integer clipWidth, final Integer clipHeight) { final MontageRelativePosition relativePosition = canvasId.getRelativePosition(); if (relativePosition != null) { final double[] clipOffsets = canvasId.getClipOffsets(); LOG.debug("clipForMontagePair: {} offsets are {}, {}", canvasId, clipOffsets[0], clipOffsets[1]); switch (relativePosition) { case TOP: case BOTTOM: if (clipHeight != null) { y = y + clipOffsets[1]; height = clipHeight; } break; case LEFT: case RIGHT: if (clipWidth != null) { x = x + clipOffsets[0]; width = clipWidth; } break; } } }
RenderParameters implements Serializable { public void clipForMontagePair(final CanvasId canvasId, final Integer clipWidth, final Integer clipHeight) { final MontageRelativePosition relativePosition = canvasId.getRelativePosition(); if (relativePosition != null) { final double[] clipOffsets = canvasId.getClipOffsets(); LOG.debug("clipForMontagePair: {} offsets are {}, {}", canvasId, clipOffsets[0], clipOffsets[1]); switch (relativePosition) { case TOP: case BOTTOM: if (clipHeight != null) { y = y + clipOffsets[1]; height = clipHeight; } break; case LEFT: case RIGHT: if (clipWidth != null) { x = x + clipOffsets[0]; width = clipWidth; } break; } } } }
RenderParameters implements Serializable { public void clipForMontagePair(final CanvasId canvasId, final Integer clipWidth, final Integer clipHeight) { final MontageRelativePosition relativePosition = canvasId.getRelativePosition(); if (relativePosition != null) { final double[] clipOffsets = canvasId.getClipOffsets(); LOG.debug("clipForMontagePair: {} offsets are {}, {}", canvasId, clipOffsets[0], clipOffsets[1]); switch (relativePosition) { case TOP: case BOTTOM: if (clipHeight != null) { y = y + clipOffsets[1]; height = clipHeight; } break; case LEFT: case RIGHT: if (clipWidth != null) { x = x + clipOffsets[0]; width = clipWidth; } break; } } } RenderParameters();  RenderParameters(final String tileSpecUrl,
                            final double x,
                            final double y,
                            final int width,
                            final int height,
                            final Double scale); }
RenderParameters implements Serializable { public void clipForMontagePair(final CanvasId canvasId, final Integer clipWidth, final Integer clipHeight) { final MontageRelativePosition relativePosition = canvasId.getRelativePosition(); if (relativePosition != null) { final double[] clipOffsets = canvasId.getClipOffsets(); LOG.debug("clipForMontagePair: {} offsets are {}, {}", canvasId, clipOffsets[0], clipOffsets[1]); switch (relativePosition) { case TOP: case BOTTOM: if (clipHeight != null) { y = y + clipOffsets[1]; height = clipHeight; } break; case LEFT: case RIGHT: if (clipWidth != null) { x = x + clipOffsets[0]; width = clipWidth; } break; } } } RenderParameters();  RenderParameters(final String tileSpecUrl,
                            final double x,
                            final double y,
                            final int width,
                            final int height,
                            final Double scale); @SuppressWarnings("UnusedDeclaration") Double getMinBoundsMinX(); @SuppressWarnings("UnusedDeclaration") Double getMinBoundsMinY(); @SuppressWarnings("UnusedDeclaration") Double getMinBoundsMaxX(); @SuppressWarnings("UnusedDeclaration") Double getMinBoundsMaxY(); static RenderParameters parseCommandLineArgs(final String[] args); static RenderParameters parseJson(final String jsonText); static RenderParameters parseJson(final Reader jsonReader); static RenderParameters parseJson(final File jsonFile); static RenderParameters loadFromUrl(final String url); void clipForMontagePair(final CanvasId canvasId,
                                   final Integer clipWidth,
                                   final Integer clipHeight); void initializeDerivedValues(); @SuppressWarnings("UnusedDeclaration") double getRes(); double getRes(final double effectiveScale); String getOut(); double getX(); double getY(); int getWidth(); int getHeight(); double getScale(); Double getMinIntensity(); Double getMaxIntensity(); void setMinIntensity(final Double minIntensity); void setMaxIntensity(final Double maxIntensity); void setScale(final double scale); boolean isConvertToGray(); void setConvertToGray(final Boolean convertToGray); float getQuality(); int getNumberOfThreads(); void setNumberOfThreads(final int numberOfThreads); boolean skipInterpolation(); void setSkipInterpolation(final Boolean skipInterpolation); boolean binaryMask(); void setBinaryMask(final Boolean binaryMask); boolean excludeMask(); void setExcludeMask(final Boolean excludeMask); void setDoFilter(final Boolean filter); void setAddWarpFieldDebugOverlay(final boolean addWarpFieldDebugOverlay); void setBackgroundRGBColor(final Integer backgroundRGBColor); boolean isFillWithNoise(); void setFillWithNoise(final Boolean fillWithNoise); Set<String> getChannelNames(); void setChannels(final String channels); boolean hasTileSpecs(); int numberOfTileSpecs(); List<TileSpec> getTileSpecs(); void addTileSpec(final TileSpec tileSpec); @SuppressWarnings("UnusedDeclaration") void addTileSpecs(final Collection<TileSpec> tileSpec); void removeTileSpecsOutsideSet(final Set<String> tileIdsToKeep); void sortTileSpecs(final Comparator<TileSpec> comparator); void flattenTransforms(); void setMipmapPathBuilder(final MipmapPathBuilder mipmapPathBuilder); boolean hasFilters(); List<Filter> getFilters(); void setFilterSpecs(final List<FilterSpec> filterSpecs); void validate(); boolean hasMasks(); BufferedImage openTargetImage(); BufferedImage openTargetImage(final int imageType); @Override String toString(); String toJson(); @SuppressWarnings("UnusedDeclaration") void deriveMinimalBoundingBox(final boolean force, final double... padding); }
RenderParameters implements Serializable { public void clipForMontagePair(final CanvasId canvasId, final Integer clipWidth, final Integer clipHeight) { final MontageRelativePosition relativePosition = canvasId.getRelativePosition(); if (relativePosition != null) { final double[] clipOffsets = canvasId.getClipOffsets(); LOG.debug("clipForMontagePair: {} offsets are {}, {}", canvasId, clipOffsets[0], clipOffsets[1]); switch (relativePosition) { case TOP: case BOTTOM: if (clipHeight != null) { y = y + clipOffsets[1]; height = clipHeight; } break; case LEFT: case RIGHT: if (clipWidth != null) { x = x + clipOffsets[0]; width = clipWidth; } break; } } } RenderParameters();  RenderParameters(final String tileSpecUrl,
                            final double x,
                            final double y,
                            final int width,
                            final int height,
                            final Double scale); @SuppressWarnings("UnusedDeclaration") Double getMinBoundsMinX(); @SuppressWarnings("UnusedDeclaration") Double getMinBoundsMinY(); @SuppressWarnings("UnusedDeclaration") Double getMinBoundsMaxX(); @SuppressWarnings("UnusedDeclaration") Double getMinBoundsMaxY(); static RenderParameters parseCommandLineArgs(final String[] args); static RenderParameters parseJson(final String jsonText); static RenderParameters parseJson(final Reader jsonReader); static RenderParameters parseJson(final File jsonFile); static RenderParameters loadFromUrl(final String url); void clipForMontagePair(final CanvasId canvasId,
                                   final Integer clipWidth,
                                   final Integer clipHeight); void initializeDerivedValues(); @SuppressWarnings("UnusedDeclaration") double getRes(); double getRes(final double effectiveScale); String getOut(); double getX(); double getY(); int getWidth(); int getHeight(); double getScale(); Double getMinIntensity(); Double getMaxIntensity(); void setMinIntensity(final Double minIntensity); void setMaxIntensity(final Double maxIntensity); void setScale(final double scale); boolean isConvertToGray(); void setConvertToGray(final Boolean convertToGray); float getQuality(); int getNumberOfThreads(); void setNumberOfThreads(final int numberOfThreads); boolean skipInterpolation(); void setSkipInterpolation(final Boolean skipInterpolation); boolean binaryMask(); void setBinaryMask(final Boolean binaryMask); boolean excludeMask(); void setExcludeMask(final Boolean excludeMask); void setDoFilter(final Boolean filter); void setAddWarpFieldDebugOverlay(final boolean addWarpFieldDebugOverlay); void setBackgroundRGBColor(final Integer backgroundRGBColor); boolean isFillWithNoise(); void setFillWithNoise(final Boolean fillWithNoise); Set<String> getChannelNames(); void setChannels(final String channels); boolean hasTileSpecs(); int numberOfTileSpecs(); List<TileSpec> getTileSpecs(); void addTileSpec(final TileSpec tileSpec); @SuppressWarnings("UnusedDeclaration") void addTileSpecs(final Collection<TileSpec> tileSpec); void removeTileSpecsOutsideSet(final Set<String> tileIdsToKeep); void sortTileSpecs(final Comparator<TileSpec> comparator); void flattenTransforms(); void setMipmapPathBuilder(final MipmapPathBuilder mipmapPathBuilder); boolean hasFilters(); List<Filter> getFilters(); void setFilterSpecs(final List<FilterSpec> filterSpecs); void validate(); boolean hasMasks(); BufferedImage openTargetImage(); BufferedImage openTargetImage(final int imageType); @Override String toString(); String toJson(); @SuppressWarnings("UnusedDeclaration") void deriveMinimalBoundingBox(final boolean force, final double... padding); @Parameter(names = "--help", description = "Display this note", help = true)
    transient boolean help; @Parameter(names = {"--res", "--meshCellSize"}, description = " Mesh resolution, specified by the desired size of a mesh cell (triangle) in pixels")
    public double meshCellSize; @Parameter(names = {"--min_res", "--minMeshCellSize"}, description = " Minimal mesh resolution, specified by the desired size of a mesh cell (triangle) in pixels")
    public double minMeshCellSize; @Parameter(names = "--in", description = "Path to the input image if any")
    public String in; @Parameter(names = "--out", description = "Path to the output image", required = true)
    public String out; @Parameter(names = "--x", description = "Target image left coordinate")
    public double x; @Parameter(names = "--y", description = "Target image top coordinate")
    public double y; @Parameter(names = "--width", description = "Target image width")
    public int width; @Parameter(names = "--height", description = "Target image height")
    public int height; @Parameter(names = "--scale", description = "scale factor applied to the target image")
    public double scale; @Parameter(names = "--area_offset", description = "add bounding box offset")
    public boolean areaOffset; @Parameter(names = "--minIntensity", description = "minimum intensity value for all tile specs")
    public Double minIntensity; @Parameter(names = "--maxIntensity", description = "maximum intensity value for all tile specs")
    public Double maxIntensity; @Parameter(names = "--gray", description = "convert output to gray scale image")
    public boolean convertToGray; @Parameter(names = "--quality", description = "JPEG quality float [0, 1]")
    public float quality; @Parameter(names = "--threads", description = "Number of threads to be used")
    public int numberOfThreads; @Parameter(names = "--skip_interpolation", description = "enable sloppy but fast rendering by skipping interpolation")
    public boolean skipInterpolation; @Parameter(names = "--binary_mask", description = "render only 100% opaque pixels")
    public boolean binaryMask; @Parameter(names = "--exclude_mask", description = "exclude mask when rendering")
    public boolean excludeMask; @Parameter(names = "--parameters_url", description = "URL to base JSON parameters file (to be applied to any unspecified or default parameters)")
    public String parametersUrl; @Parameter(names = "--addWarpFieldDebugOverlay", description = "render warp field debug overlay")
    public boolean addWarpFieldDebugOverlay; static final double DEFAULT_MESH_CELL_SIZE; }