if (roi instanceof ROI) { ROI roiImage = (ROI) roi; Rectangle bounds = roiImage.getBounds(); if (!(bounds.isEmpty())) { PlanarImage image = roiImage.getAsImage();
if (!roi.getBounds().intersects(rasterBounds)) { essential = false; } else {
this.hasROI = roi != null; if (hasROI) { this.roiBounds = roi.getBounds(); setProperty("roi", roi);
if (hasROI) { roi = roiProp; roiBounds = roi.getBounds();
/** * Constructor * * @param source a RenderedImage. * @param config configurable attributes of the image * * @param layout an ImageLayout optionally containing the tile grid layout, SampleModel, and ColorModel, or null. * * @param table an instance of RangeLookupTable that defines the mappings from source value ranges to destination values * * @param defaultValue either a value to use for all unmatched source values or null to indicate that unmatched values should pass-through to the * destination * @param roi {@link ROI} object used for masking image areas. * * @see RangeLookupDescriptor */ public RangeLookupOpImage(RenderedImage source, Map config, ImageLayout layout, RangeLookupTable table, Number defaultValue, ROI roi) { super(source, layout, config, true); this.table = table; this.defaultValue = defaultValue; this.hasDefault = defaultValue != null; this.roi = roi; hasROI = roi != null; if (hasROI) { roiBounds = roi.getBounds(); } }
/** * Constructor * * @param source a RenderedImage. * @param config configurable attributes of the image * * @param layout an ImageLayout optionally containing the tile grid layout, SampleModel, and ColorModel, or null. * * @param table an instance of RangeLookupTable that defines the mappings from source value ranges to destination values * * @param defaultValue either a value to use for all unmatched source values or null to indicate that unmatched values should pass-through to the * destination * @param roi {@link ROI} object used for masking image areas. * * @see RangeLookupDescriptor */ public RangeLookupOpImage(RenderedImage source, Map config, ImageLayout layout, RangeLookupTable table, Number defaultValue, ROI roi) { super(source, layout, config, true); this.table = table; this.defaultValue = defaultValue; this.hasDefault = defaultValue != null; this.roi = roi; hasROI = roi != null; if (hasROI) { roiBounds = roi.getBounds(); } }
AffineTransform inverse = sTx.createInverse(); ROI newROI = this.roi != null ? this.roi.transform(inverse) : null; similarROI = newROI != null && newROI.intersects(r.getBounds()); } catch (NoninvertibleTransformException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); try { ROI newROI = computeScaledROI(scalingParams); similarROI = newROI != null && newROI.intersects(r.getBounds()); } catch (NoninvertibleTransformException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e);
roiarr = new ROI[] {roi}; if (roiarr != null && roiarr[0].getBounds().isEmpty()) { throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));
if (!srcBounds.contains(srcROI.getBounds())) { srcROI = srcROI.intersect(new ROIShape(srcBounds));
if (!srcBounds.contains(srcROI.getBounds())) { srcROI = srcROI.intersect(new ROIShape(srcBounds));
private Rectangle getRoiBounds() { ParameterBlock pb = this.op.getParameterBlock(); ROI[] rois = (ROI[]) pb.getObjectParameter(2); return rois[0].getBounds(); }
/** * Constructs an ImageFunctionOpImage. * * @param width The output image width. * @param height The output image height. */ public ImageFunctionOpImage(ImageFunction function, int minX, int minY, int width, int height, float xScale, float yScale, float xTrans, float yTrans, ROI roi, Range nodata, float destNoData, Map config, ImageLayout layout) { super(layout, config, sampleModelHelper(function.getNumElements() * (function.isComplex() ? 2 : 1), layout), minX, minY, width, height); // Cache the parameters. this.function = function instanceof ImageFunctionJAIEXT ? (ImageFunctionJAIEXT) function : new ImageFunctionJAIEXTWrapper(function); this.xScale = xScale; this.yScale = yScale; this.xTrans = xTrans; this.yTrans = yTrans; // Check if ROI is present hasROI = roi != null; if (hasROI) { this.roiBounds = roi.getBounds(); this.roi = roi; } // Check on NoData if (nodata != null) { this.nodata = RangeFactory.convertToFloatRange(nodata); } this.destNoData = destNoData; }
public ColorIndexerOpImage(RenderedImage image, ColorIndexer palette, ROI roi, Range nodata, int destNoData, RenderingHints hints) { super(image, buildLayout(image, palette.toIndexColorModel()), hints, false); this.icm = palette.toIndexColorModel(); this.setSource(image, 0); this.palette = palette; // Checking for NoData hasNoData = nodata != null; if (hasNoData) { this.nodata = RangeFactory.convertToByteRange(nodata); initLookupTable(); } // Checking for ROI hasROI = roi != null; if (hasROI) { this.roi = roi; roiBounds = roi.getBounds(); } // Setting the Index for the NoData value this.destNoData = (byte) (destNoData & 0xFF); // Definition of the possible cases that can be found // caseA = no ROI nor No Data // caseB = ROI present but No Data not present // caseC = No Data present but ROI not present // Last case not defined = both ROI and No Data are present caseA = !hasROI && !hasNoData; caseB = hasROI && !hasNoData; caseC = !hasROI && hasNoData; }
public ColorIndexerOpImage(RenderedImage image, ColorIndexer palette, ROI roi, Range nodata, int destNoData, RenderingHints hints) { super(image, buildLayout(image, palette.toIndexColorModel()), hints, false); this.icm = palette.toIndexColorModel(); this.setSource(image, 0); this.palette = palette; // Checking for NoData hasNoData = nodata != null; if (hasNoData) { this.nodata = RangeFactory.convertToByteRange(nodata); initLookupTable(); } // Checking for ROI hasROI = roi != null; if (hasROI) { this.roi = roi; roiBounds = roi.getBounds(); } // Setting the Index for the NoData value this.destNoData = (byte) (destNoData & 0xFF); // Definition of the possible cases that can be found // caseA = no ROI nor No Data // caseB = ROI present but No Data not present // caseC = No Data present but ROI not present // Last case not defined = both ROI and No Data are present caseA = !hasROI && !hasNoData; caseB = hasROI && !hasNoData; caseC = !hasROI && hasNoData; }
@Test public void addEmptyROIToNonEmptyROI() { ROIGeometry nonEmpty = createRectROI(0, 0, 10, 10); ROIGeometry empty = createEmptyROI(); ROI result = nonEmpty.add(empty); assertTrue( result.getBounds().equals(nonEmpty.getBounds()) ); }
@Test public void addNonEmptyROIToEmpty() { ROIGeometry nonEmpty = createRectROI(0, 0, 10, 10); ROIGeometry empty = createEmptyROI(); ROI result = empty.add(nonEmpty); assertTrue( result.getBounds().equals(nonEmpty.getBounds()) ); }