Refine search
private int countBands(List<GridCoverage2D> coverages) { int count = 0; for (GridCoverage2D coverage : coverages) { count += coverage.getRenderedImage().getSampleModel().getNumBands(); } return count; }
/** * The BandMerge operation takes indexed images and expands them, however in the context of * coverage view band merging we don't normally want that, e.g., raster mask bands are * represented as indexed but we really want to keep them in their binary, single band form. To * do so, the IndexColorModel is replaced by a ComponentColorModel * * @param coverage * @return */ private GridCoverage2D prepareForBandMerge(GridCoverage2D coverage) { RenderedImage ri = coverage.getRenderedImage(); SampleModel sampleModel = ri.getSampleModel(); if (sampleModel.getNumBands() == 1 && ri.getColorModel() instanceof IndexColorModel) { ImageWorker worker = new ImageWorker(ri); worker.removeIndexColorModel(); RenderedImage formatted = worker.getRenderedImage(); return new GridCoverageFactory() .create( coverage.getName(), formatted, coverage.getGridGeometry(), coverage.getSampleDimensions(), new GridCoverage[] {coverage}, coverage.getProperties()); } return coverage; }
@Test public void testBandsFlagsView() throws Exception { // creation in the setup would have failed before the fix for // [GEOT-6168] CoverageView setup fails if one of the source bands has an indexed color // model CoverageInfo info = getCatalog().getCoverageByName(BANDS_FLAGS_VIEW); GridCoverageReader reader = info.getGridCoverageReader(null, null); GridCoverage2D coverage = (GridCoverage2D) reader.read(null); assertEquals(11, coverage.getRenderedImage().getSampleModel().getNumBands()); coverage.dispose(true); } }
/** * Returns the number of bands in the {@linkplain #image}. * * @see #retainBands * @see #retainFirstBand * @see SampleModel#getNumBands */ public final int getNumBands() { return image.getSampleModel().getNumBands(); }
/** * Computes the image size based on the SampleModel and image dimension * * @param image * @return */ static long computeImageSize(RenderedImage image) { long bits = 0; final int bands = image.getSampleModel().getNumBands(); for (int i = 0; i < bands; i++) { bits += image.getSampleModel().getSampleSize(i); } return (long) Math.ceil(bits / 8) * image.getWidth() * image.getHeight(); }
/** * Constructs a sample dimension with a set of categories from an other sample dimension. * * @param band The originating sample dimension. * @param image The image to be wrapped by {@link GridCoverage}. * @param bandNumber The band number. */ private RenderedSampleDimension( final GridSampleDimension band, final RenderedImage image, final int bandNumber) { super(band); final SampleModel model = image.getSampleModel(); this.band = bandNumber; this.numBands = model.getNumBands(); this.type = TypeMap.getSampleDimensionType(model, bandNumber); }
private GridSampleDimension[] getOutputSampleDimensions( GridSampleDimension[] sampleDimensions, RenderedImage data) { int outputNumBands = data.getSampleModel().getNumBands(); if (outputNumBands == sampleDimensions.length) { return sampleDimensions;
private GridSampleDimension[] getSampleDimensions(final RenderedImage coverageRaster) throws IOException { GridSampleDimension[] bands = rasterInfo.getGridSampleDimensions(); // may the image have been promoted? build the correct band info then final int imageBands = coverageRaster.getSampleModel().getNumBands(); if (bands.length == 1 && imageBands > 1) { LOGGER.fine( coverageName + " was promoted from 1 to " + coverageRaster.getSampleModel().getNumBands() + " bands, returning an appropriate set of GridSampleDimension"); // stolen from super.createCoverage: final ColorModel cm = coverageRaster.getColorModel(); bands = new GridSampleDimension[imageBands]; // setting bands names. for (int i = 0; i < imageBands; i++) { final ColorInterpretation colorInterpretation; colorInterpretation = TypeMap.getColorInterpretation(cm, i); if (colorInterpretation == null) { throw new IOException("Unrecognized sample dimension type"); } bands[i] = new GridSampleDimension(colorInterpretation.name()); } } return bands; }
protected final int getNumBands(final IIOImage image) { return image.hasRaster() ? image.getRaster().getNumBands() : image.getRenderedImage().getSampleModel().getNumBands(); }
image2 = normalizeImage(image2); this.bands = image1.getSampleModel().getNumBands(); final boolean hasAlpha = image1.getColorModel().hasAlpha(); if (bands > 4 || (bands == 2 && !hasAlpha) || (bands == 3 && hasAlpha)) {
assert inputImage.getSampleModel().getNumBands() == 1 : inputImage; final int dataType = inputImage.getSampleModel().getDataType(); RenderedImage result = inputImage; if (!Double.isNaN(gammaValue) && Math.abs(gammaValue - 1.0) > 1E-6) { assert result.getSampleModel().getNumBands() == 1 : result; return result;
final GridSampleDimension[] src, final GridSampleDimension[] dst) { final int numBands = image.getSampleModel().getNumBands(); if (src != null && src.length != numBands) { throw new IllegalArgumentException( name, RectIterFactory.create(image, null), image.getSampleModel(), null, null,
private GridCoverage2D prepareCoverage(RenderedImage image) throws IOException { // creating bands final SampleModel sm = image.getSampleModel(); final ColorModel cm = image.getColorModel(); final int numBands = sm.getNumBands(); final GridSampleDimension[] bands = new GridSampleDimension[numBands]; // setting bands names. for (int i = 0; i < numBands; i++) { final ColorInterpretation colorInterpretation = TypeMap.getColorInterpretation(cm, i); if (colorInterpretation == null) throw new IOException("Unrecognized sample dimension type"); bands[i] = new GridSampleDimension(colorInterpretation.name()); } return coverageFactory.create( rasterManager.getCoverageIdentifier(), image, new GeneralEnvelope(bbox), bands, null, null); }
final int numBands = src.getSampleModel().getNumBands(); final int[] rgba = new int[numBands]; final boolean discriminantTransparency = transparency != Transparency.OPAQUE;
/** * Performs a contrast enhancement operation on the input image. Note that not all the contrast * enhancement operations have been implemented in a way that is generic enough o handle all * data types. * * @param inputImage the input {@link RenderedImage} to work on. * @param hints {@link Hints} to control the contrast enhancement process. * @return a {@link RenderedImage} on which a contrast enhancement has been performed. */ private RenderedImage performContrastEnhancement(ImageWorker inputWorker, final Hints hints) { inputWorker.setRenderingHints(hints); if (contrastEnhancementMethod != null) { RenderedImage inputImage = inputWorker.getRenderedImage(); assert inputImage.getSampleModel().getNumBands() == 1 : inputImage; ContrastEnhancementType ceType = ContrastEnhancementType.getType(contrastEnhancementMethod); return ceType.process(inputWorker, hints, contrastEnhancementMethod.getParameters()); } return inputWorker.getRenderedImage(); }
SampleModel firstSampleModel = first.getSampleModel(); int firstBands = firstSampleModel.getNumBands(); int firstSampleSize = firstSampleModel.getSampleSize()[0]; boolean hasIndexedColorModels = firstColorModel instanceof IndexColorModel; for (int i = 1; i < numSources; i++) { RenderedImage source = (RenderedImage) sources.get(i); SampleModel sourceSampleModel = source.getSampleModel(); ColorModel sourceColorModel = source.getColorModel(); int sourceBands = sourceSampleModel.getNumBands(); int sourceDataType = sourceSampleModel.getDataType(); if (sourceDataType == DataBuffer.TYPE_UNDEFINED) {
protected void handleJAIEXTParams( ParameterBlockJAI parameters, ParameterValueGroup parameters2) { if (JAIExt.isJAIExtOperation(STATS)) { GridCoverage2D source = (GridCoverage2D) parameters2.parameter("source0").getValue(); // Handle ROI and NoData handleROINoDataInternal(parameters, source, STATS, 2, 3); // Setting the Statistic operation parameters.set(new StatsType[] {StatsType.EXTREMA}, 6); // Check on the band numnber int b = source.getRenderedImage().getSampleModel().getNumBands(); int[] indexes = new int[b]; for (int i = 0; i < b; i++) { indexes[i] = i; } parameters.set(indexes, 5); } } }
protected void handleJAIEXTParams( ParameterBlockJAI parameters, ParameterValueGroup parameters2) { if (JAIExt.isJAIExtOperation(STATS)) { GridCoverage2D source = (GridCoverage2D) parameters2.parameter("source0").getValue(); // Handle ROI and NoData handleROINoDataInternal(parameters, source, STATS, 2, 3); // Setting the Statistic operation parameters.set(new StatsType[] {StatsType.HISTOGRAM}, 6); // Check on the band numnber int b = source.getRenderedImage().getSampleModel().getNumBands(); int[] indexes = new int[b]; for (int i = 0; i < b; i++) { indexes[i] = i; } parameters.set(indexes, 5); } } }
final int numBands = src.getSampleModel().getNumBands(); final int[] rgba = new int[numBands]; final boolean sourceHasAlpha = (numBands % 2 == 0);
final int numBands = image.getSampleModel().getNumBands(); if (hasAlpha) { retainBands(numBands - 1);