private static void configureBand(Band band05X, ImageInfo imageInfo, String unit, String description) { band05X.setUnit(unit); band05X.setDescription(description); band05X.setImageInfo(imageInfo); band05X.setNoDataValue(Double.NaN); band05X.setNoDataValueUsed(true); }
private void addBandStatistics(Element imageDisplayElem, Product product) { final List bandStatisticsElems = imageDisplayElem.getChildren(DimapProductConstants.TAG_BAND_STATISTICS); for (Object bandStatistics : bandStatisticsElems) { final Element bandStatisticsElem = (Element) bandStatistics; final String bandIndex = bandStatisticsElem.getChildTextTrim(DimapProductConstants.TAG_BAND_INDEX); final String bandName = getBandName(getRootElement(), bandIndex); if (bandName != null) { final Band band = product.getBand(bandName); if (band != null) { Stx stx = createStx(band, bandStatisticsElem); if (stx != null) { band.setStx(stx); } band.setImageInfo(createImageInfo(bandStatisticsElem)); } } } }
private void addBandsToProduct(TiffFileInfo tiffInfo, Product product) throws IOException { final ImageReadParam readParam = imageReader.getDefaultReadParam(); TIFFRenderedImage baseImage = (TIFFRenderedImage) imageReader.readAsRenderedImage(FIRST_IMAGE, readParam); SampleModel sampleModel = baseImage.getSampleModel(); final int numBands = sampleModel.getNumBands(); final int productDataType = ImageManager.getProductDataType(sampleModel.getDataType()); bandMap = new HashMap<>(numBands); for (int i = 0; i < numBands; i++) { final String bandName = String.format("band_%d", i + 1); final Band band = product.addBand(bandName, productDataType); if (tiffInfo.containsField( BaselineTIFFTagSet.TAG_COLOR_MAP) && baseImage.getColorModel() instanceof IndexColorModel) { band.setImageInfo(createIndexedImageInfo(product, baseImage, band)); } bandMap.put(band, i); } }
private static void readImageInfo(Variable variable, Band band) throws ProductIOException { final Attribute sampleValues = variable.findAttributeIgnoreCase(COLOR_TABLE_SAMPLE_VALUES); final Attribute redValues = variable.findAttributeIgnoreCase(COLOR_TABLE_RED_VALUES); final Attribute greenValues = variable.findAttributeIgnoreCase(COLOR_TABLE_GREEN_VALUES); final Attribute blueValues = variable.findAttributeIgnoreCase(COLOR_TABLE_BLUE_VALUES); final Attribute[] attributes = {sampleValues, redValues, greenValues, blueValues}; if (allAttributesAreNotNullAndHaveTheSameSize(attributes)) { final ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[sampleValues.getLength()]; for (int i = 0; i < points.length; i++) { final int red = redValues.getNumericValue(i).intValue(); final int green = greenValues.getNumericValue(i).intValue(); final int blue = blueValues.getNumericValue(i).intValue(); final Color color = new Color(red, green, blue); points[i] = new ColorPaletteDef.Point(sampleValues.getNumericValue(i).doubleValue(), color); } band.setImageInfo(new ImageInfo(new ColorPaletteDef(points))); } }
private void adjustImageInfos(RasterDataNode raster) { if (!isAdjustingImageInfos) { try { isAdjustingImageInfos = true; final String variableName = AbstractTimeSeries.rasterToVariableName(raster.getName()); final List<Band> bandList = getBandsForVariable(variableName); final ImageInfo imageInfo = raster.getImageInfo(ProgressMonitor.NULL); if (imageInfo != null) { for (Band band : bandList) { if (band != raster) { band.setImageInfo(imageInfo.createDeepCopy()); } } } } finally { isAdjustingImageInfos = false; } } }
private void addBandsToProduct(TiffFileInfo tiffFileInfo, Product product) throws IOException { final ImageTypeSpecifier rawImageType = imageReader.getRawImageType(0); final int numBands = rawImageType.getNumBands(); final int productDataType = ImageManager.getProductDataType(rawImageType.getSampleModel().getDataType()); bandMap = new HashMap<>(numBands); for (int bandIndex = 0; bandIndex < numBands; bandIndex++) { final String bandName = String.format("band_%d", bandIndex + 1); final Band band = product.addBand(bandName, productDataType); band.setSourceImage(getMultiLevelImageSourceImage(band, bandIndex)); if (tiffFileInfo.containsField(BaselineTIFFTagSet.TAG_COLOR_MAP) && rawImageType.getColorModel() instanceof IndexColorModel) { final IndexColorModel colorModel = (IndexColorModel) rawImageType.getColorModel(); band.setImageInfo(createIndexedImageInfo(product, band, colorModel)); } bandMap.put(band, bandIndex); } }
private void addDeltaBands() { final Band deltaLonBand = targetProduct.addBand("delta_lon_angular", "longitude - LON"); deltaLonBand.setUnit("deg"); deltaLonBand.setDescription("Delta between old longitude and new longitude in degree"); deltaLonBand.setNoDataValueUsed(true); deltaLonBand.setNoDataValue(noDataValue == null ? Double.NaN : noDataValue); deltaLonBand.setImageInfo(createDeltaBandImageInfo(-0.015, +0.015)); final Band deltaLatBand = targetProduct.addBand("delta_lat_angular", "latitude - LAT"); deltaLatBand.setUnit("deg"); deltaLatBand.setDescription("Delta between old latitude and new latitude in degree"); deltaLatBand.setNoDataValueUsed(true); deltaLatBand.setNoDataValue(noDataValue == null ? Double.NaN : noDataValue); deltaLatBand.setImageInfo(createDeltaBandImageInfo(-0.01, +0.01)); final Band deltaLonMetBand = targetProduct.addBand("delta_lon_metric", "cos(rad(LAT)) * 6378137 * rad(longitude - LON)"); deltaLonMetBand.setUnit("m"); deltaLonMetBand.setDescription("Delta between old longitude and new longitude in meters"); deltaLonMetBand.setNoDataValueUsed(true); deltaLonMetBand.setNoDataValue(noDataValue == null ? Double.NaN : noDataValue); deltaLonMetBand.setImageInfo(createDeltaBandImageInfo(-1500.0, +1500.0)); final Band deltaLatMetBand = targetProduct.addBand("delta_lat_metric", "6378137 * rad(latitude - LAT)"); deltaLatMetBand.setUnit("m"); deltaLatMetBand.setDescription("Delta between old latitude and new latitude in meters"); deltaLatMetBand.setNoDataValueUsed(true); deltaLatMetBand.setNoDataValue(noDataValue == null ? Double.NaN : noDataValue); deltaLatMetBand.setImageInfo(createDeltaBandImageInfo(-1000.0, +1000.0)); }
private void attachColoredBand() { final Band band = createDataBand(0, 255, COLORED_BAND_NAME); ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[2]; points[0] = new ColorPaletteDef.Point(128, Color.BLUE); points[1] = new ColorPaletteDef.Point(255, Color.BLACK); ColorPaletteDef colors = new ColorPaletteDef(points); band.setImageInfo(new ImageInfo(colors)); product.addBand(band); }
private void addSpecifiedBandOfGivenProduct(String nodeName, Product product) { if (isProductCompatible(product, nodeName)) { final RasterDataNode raster = product.getRasterDataNode(nodeName); TimeCoding rasterTimeCoding = GridTimeCoding.create(product); final ProductData.UTC rasterStartTime = rasterTimeCoding.getStartTime(); final ProductData.UTC rasterEndTime = rasterTimeCoding.getEndTime(); Guardian.assertNotNull("rasterStartTime", rasterStartTime); final String bandName = variableToRasterName(nodeName, rasterTimeCoding); if (!tsProduct.containsBand(bandName)) { // band not already contained if (isAutoAdjustingTimeCoding() || !isTimeCodingSet()) { // automatically setting time coding // OR // first band to add to time series; time bounds of this band will be used // as ts-product's time bounds, no matter if auto adjust is true or false autoAdjustTimeInformation(rasterStartTime, rasterEndTime); } if (getTimeCoding().contains(rasterTimeCoding)) { // add only bands which are in the time bounds final Band addedBand = addBand(raster, rasterTimeCoding, bandName); final List<Band> bandsForVariable = getBandsForVariable(nodeName); if (!bandsForVariable.isEmpty()) { final ImageInfo imageInfo = bandsForVariable.get(0).getImageInfo(ProgressMonitor.NULL); addedBand.setImageInfo(imageInfo.createDeepCopy()); } } // todo no bands added message } } }
log("creating histogram for band '" + band.getName() + "'..."); final ImageInfo imageInfo = band.createDefaultImageInfo(_histoSkipRatios, ProgressMonitor.NULL); band.setImageInfo(imageInfo); if (colorPaletteDef != null) { if (band.getIndexCoding() != null) {
private void attachIndexCodedBand() { final Band band = createDataBand(0, 1, INDEX_CODED_BAND_NAME); final IndexCoding indexCoding = new IndexCoding(INDEX_CODING_NAME); indexCoding.addIndex("i0", 0, "i0"); indexCoding.addIndex("i1", 1, "i1"); band.setSampleCoding(indexCoding); ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[2]; points[0] = new ColorPaletteDef.Point(0, Color.RED); points[1] = new ColorPaletteDef.Point(1, Color.GREEN); ColorPaletteDef colors = new ColorPaletteDef(points); band.setImageInfo(new ImageInfo(colors)); product.getIndexCodingGroup().add(indexCoding); product.addBand(band); }
band.setImageInfo(imageInfo);
targetBand.setImageInfo(sourceImageInfo.createDeepCopy());
realBand.setImageInfo(imageInfo.clone());
targetBand.setImageInfo(imageInfo.clone());
destBand.setImageInfo(sourceImageInfo.createDeepCopy());
band1.setUnit("unit for " + band1.getName()); band1.setDescription(band1.getName() + "-Description"); band1.setImageInfo(createImageInfo()); band1.setSolarFlux(0.12f); band1.setSpectralWavelength(23.45f);
assertArrayEquals(new int[]{255, 255, 255}, pixel11); band2.setImageInfo(imageInfo); image = ImageManager.getInstance().createColoredBandImage(new RasterDataNode[]{band2}, null, 0); image.getData().getPixel(0, 0, pixel00);