/** * Constructs a new environment for the given raster data region. * Should only be used if evaluation takes place at image level zero. * * @param offsetX the x-offset of the raster region * @param offsetY the y-offset of the raster region * @param regionWidth the width of the raster region * @param regionHeight the height of the raster region */ public RasterDataEvalEnv(int offsetX, int offsetY, int regionWidth, int regionHeight) { this(offsetX, offsetY, regionWidth, regionHeight, new LevelImageSupport(regionWidth, regionHeight, ResolutionLevel.MAXRES)); }
public final int getSourceHeight(int destHeight) { return double2int(getScale() * destHeight, 1, getSourceHeight()); }
public final int getSourceWidth(int destWidth) { return double2int(getScale() * destWidth, 1, getSourceWidth()); }
public final int getSourceY(int ty) { return getSourceCoord(ty, 0, getSourceHeight() - 1); }
protected final int getSourceWidth(int targetWidth) { return levelImageSupport.getSourceWidth(targetWidth); }
/** * Gets the absolute pixel's x-coordinate within the data raster (from image at level zero in an image pyramid). * * @return the current source pixel's x-coordinate */ public final int getPixelX() { return levelImageSupport.getSourceX(offsetX + elemIndex % regionWidth); }
@Test public void testGetSourceY() { final int h = levelImageSupport.getSourceHeight(); assertEquals(1120, h); assertEquals(0, levelImageSupport.getSourceY(0)); assertEquals(1, levelImageSupport.getSourceY(1)); assertEquals(h - 1, levelImageSupport.getSourceY(h - 1)); assertEquals(h - 1, levelImageSupport.getSourceY(h)); assertEquals(h - 1, levelImageSupport.getSourceY(h + 1)); }
@Test public void testGetSourceX() { final int w = levelImageSupport.getSourceWidth(); assertEquals(760, w); assertEquals(0, levelImageSupport.getSourceX(0)); assertEquals(1, levelImageSupport.getSourceX(1)); assertEquals(w - 1, levelImageSupport.getSourceX(w - 1)); assertEquals(w - 1, levelImageSupport.getSourceX(w)); assertEquals(w - 1, levelImageSupport.getSourceX(w + 1)); }
public final int getSourceX(int tx) { return getSourceCoord(tx, 0, getSourceWidth() - 1); }
/** * Gets the absolute pixel's y-coordinate within the data raster (from image at level zero in an image pyramid). * * @return the current source pixel's y-coordinate */ public final int getPixelY() { return levelImageSupport.getSourceY(offsetY + elemIndex / regionWidth); }
protected final int getSourceHeight(int targetHeight) { return levelImageSupport.getSourceHeight(targetHeight); }
public final int getSourceCoord(double destCoord, int min, int max) { return double2int(getScale() * destCoord, min, max); }
public final int getLevel() { return levelImageSupport.getLevel(); }
protected final double getScale() { return levelImageSupport.getScale(); }
protected final int getSourceCoord(double targetCoord, int min, int max) { return levelImageSupport.getSourceCoord(targetCoord, min, max); }
@Test public void testGetSourceWidth() { final int w = levelImageSupport.getSourceWidth(); assertEquals(760, w); assertEquals(1, levelImageSupport.getSourceWidth(0)); assertEquals(1, levelImageSupport.getSourceWidth(1)); assertEquals(w - 1, levelImageSupport.getSourceWidth(w - 1)); assertEquals(w, levelImageSupport.getSourceWidth(w)); assertEquals(w, levelImageSupport.getSourceWidth(w + 1)); }
protected final int getSourceX(int targetX) { return levelImageSupport.getSourceX(targetX); }
protected final int getSourceY(int targetY) { return levelImageSupport.getSourceY(targetY); }
@Test public void testGetSourceHeight() { final int h = levelImageSupport.getSourceHeight(); assertEquals(1120, h); assertEquals(1, levelImageSupport.getSourceHeight(0)); assertEquals(1, levelImageSupport.getSourceHeight(1)); assertEquals(h - 1, levelImageSupport.getSourceHeight(h - 1)); assertEquals(h, levelImageSupport.getSourceHeight(h)); assertEquals(h, levelImageSupport.getSourceHeight(h + 1)); }
@Test public void testGetSourceWidth_sizeOdd() { final LevelImageSupport levelImageSupport = createLevelSupport(955); assertEquals(1, levelImageSupport.getSourceWidth(0)); assertEquals(8, levelImageSupport.getSourceWidth(1)); assertEquals(952, levelImageSupport.getSourceWidth(119)); assertEquals(955, levelImageSupport.getSourceWidth(120)); assertEquals(955, levelImageSupport.getSourceWidth(130)); }