private ImageInfo createDeltaBandImageInfo(double p1, double p2) { return new ImageInfo(new ColorPaletteDef(new ColorPaletteDef.Point[]{ new ColorPaletteDef.Point(p1, new Color(255, 0, 0)), new ColorPaletteDef.Point((p1 + p2) / 2, new Color(255, 255, 255)), new ColorPaletteDef.Point(p2, new Color(0, 0, 127)), })); } }
@Override public ImageInfo createDefaultImageInfo(double[] histoSkipAreas, ProgressMonitor pm) { final IndexCoding indexCoding = getIndexCoding(); if (indexCoding == null) { return super.createDefaultImageInfo(histoSkipAreas, pm); } final int sampleCount = indexCoding.getSampleCount(); Random random = new Random(0xCAFEBABE); ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[sampleCount]; for (int i = 0; i < sampleCount; i++) { String name = indexCoding.getSampleName(i); int value = indexCoding.getSampleValue(i); final Color color = new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()); points[i] = new ColorPaletteDef.Point(value, color, name); } return new ImageInfo(new ColorPaletteDef(points, points.length)); }
private static ImageInfo createIndexedImageInfo(Product product, Band band, IndexColorModel colorModel) { final IndexCoding indexCoding = new IndexCoding("color_map"); final int colorCount = colorModel.getMapSize(); final ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[colorCount]; for (int j = 0; j < colorCount; j++) { final String name = String.format("I%3d", j); indexCoding.addIndex(name, j, ""); points[j] = new ColorPaletteDef.Point(j, new Color(colorModel.getRGB(j)), name); } product.getIndexCodingGroup().add(indexCoding); band.setSampleCoding(indexCoding); return new ImageInfo(new ColorPaletteDef(points, points.length)); }
private static ImageInfo createImageInfo(Element bandStatisticsElem) { final ColorPaletteDef.Point[] points = getColorPalettePoints(bandStatisticsElem); final int numColors = getNumColors(bandStatisticsElem); final ImageInfo imageInfo = new ImageInfo(new ColorPaletteDef(points, numColors)); final Element noDataElem = bandStatisticsElem.getChild(DimapProductConstants.TAG_NO_DATA_COLOR); if (noDataElem != null) { imageInfo.setNoDataColor(createColor(noDataElem)); } final Element histomElem = bandStatisticsElem.getChild(DimapProductConstants.TAG_HISTOGRAM_MATCHING); if (histomElem != null && histomElem.getValue() != null) { imageInfo.setHistogramMatching(ImageInfo.getHistogramMatching(histomElem.getValue())); } return imageInfo; }
private static ImageInfo createIndexedImageInfo(Product product, TIFFRenderedImage baseImage, Band band) { final IndexColorModel colorModel = (IndexColorModel) baseImage.getColorModel(); final IndexCoding indexCoding = new IndexCoding("color_map"); final int colorCount = colorModel.getMapSize(); final ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[colorCount]; for (int j = 0; j < colorCount; j++) { final String name = String.format("I%3d", j); indexCoding.addIndex(name, j, ""); points[j] = new ColorPaletteDef.Point(j, new Color(colorModel.getRGB(j)), name); } product.getIndexCodingGroup().add(indexCoding); band.setSampleCoding(indexCoding); return new ImageInfo(new ColorPaletteDef(points, points.length)); }
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))); } }
public void testSetAndGetBandStatistics() { RasterDataNode rasterDataNode = createRasterDataNode(); assertEquals(null, rasterDataNode.getImageInfo()); final ImageInfo imageInfo = new ImageInfo(new ColorPaletteDef(0, 1)); rasterDataNode.setImageInfo(imageInfo); assertSame(imageInfo, rasterDataNode.getImageInfo()); }
lastSample = sample; ColorPaletteDef paletteDef = new ColorPaletteDef(points, 256); paletteDef.setAutoDistribute(propertyMap.getPropertyBool(_PROPERTY_KEY_AUTODISTRIBUTE, false)); return paletteDef;
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 ImageInfo createImageInfo() { ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[3]; points[0] = new ColorPaletteDef.Point(0.1d, Color.black); //black = new Color( 0, 0, 0, 255) points[1] = new ColorPaletteDef.Point(1.3d, Color.cyan); //cyan = new Color( 0, 255, 255, 255) points[2] = new ColorPaletteDef.Point(2.8d, Color.white); //white = new Color(255, 255, 255, 255) ColorPaletteDef paleteDefinition = new ColorPaletteDef(points, 180); final ImageInfo imageInfo = new ImageInfo(paleteDefinition); imageInfo.setNoDataColor(Color.BLUE); imageInfo.setHistogramMatching(ImageInfo.HistogramMatching.Normalize); return imageInfo; }
@Test public void testCreateLinearColorPalette() { final ColorPaletteDef cpd = new ColorPaletteDef(new ColorPaletteDef.Point[]{ new ColorPaletteDef.Point(100, Color.WHITE), new ColorPaletteDef.Point(200, Color.BLUE), new ColorPaletteDef.Point(300, Color.RED), new ColorPaletteDef.Point(400, Color.GREEN), }, 7); final ImageInfo imageInfo = new ImageInfo(cpd); imageInfo.setLogScaled(false); final Color[] palette = ImageManager.createColorPalette(imageInfo); assertNotNull(palette); assertEquals(7, palette.length); assertEquals(new Color(255, 255, 255), palette[0]); assertEquals(new Color(128, 128, 255), palette[1]); assertEquals(new Color(0, 0, 255), palette[2]); assertEquals(new Color(128, 0, 128), palette[3]); assertEquals(new Color(255, 0, 0), palette[4]); assertEquals(new Color(128, 128, 0), palette[5]); assertEquals(new Color(0, 255, 0), palette[6]); }
@Test public void testCreateLog10ColorPalette_Discrete() { final ColorPaletteDef cpd = new ColorPaletteDef(new ColorPaletteDef.Point[]{ new ColorPaletteDef.Point(1, Color.WHITE), new ColorPaletteDef.Point(10, Color.BLUE), new ColorPaletteDef.Point(100, Color.RED), new ColorPaletteDef.Point(1000, Color.GREEN), }, 7); cpd.setDiscrete(true); final ImageInfo imageInfo = new ImageInfo(cpd); imageInfo.setLogScaled(true); final Color[] palette = ImageManager.createColorPalette(imageInfo); assertNotNull(palette); assertEquals(7, palette.length); assertEquals(new Color(255, 255, 255), palette[0]); assertEquals(new Color(255, 255, 255), palette[1]); assertEquals(new Color(0, 0, 255), palette[2]); assertEquals(new Color(0, 0, 255), palette[3]); assertEquals(new Color(255, 0, 0), palette[4]); assertEquals(new Color(255, 0, 0), palette[5]); assertEquals(new Color(0, 255, 0), palette[6]); } }
@Test public void testCreateLog10ColorPalette() { final ColorPaletteDef cpd = new ColorPaletteDef(new ColorPaletteDef.Point[]{ new ColorPaletteDef.Point(1, Color.WHITE), new ColorPaletteDef.Point(10, Color.BLUE), new ColorPaletteDef.Point(100, Color.RED), new ColorPaletteDef.Point(1000, Color.GREEN), }, 7); final ImageInfo imageInfo = new ImageInfo(cpd); imageInfo.setLogScaled(true); final Color[] palette = ImageManager.createColorPalette(imageInfo); assertNotNull(palette); assertEquals(7, palette.length); assertEquals(new Color(255, 255, 255), palette[0]); assertEquals(new Color(128, 128, 255), palette[1]); assertEquals(new Color(0, 0, 255), palette[2]); assertEquals(new Color(128, 0, 128), palette[3]); assertEquals(new Color(255, 0, 0), palette[4]); assertEquals(new Color(128, 128, 0), palette[5]); assertEquals(new Color(0, 255, 0), palette[6]); }
@Test public void testCreateLinearColorPalette_Discrete() { final ColorPaletteDef cpd = new ColorPaletteDef(new ColorPaletteDef.Point[]{ new ColorPaletteDef.Point(100, Color.WHITE), new ColorPaletteDef.Point(200, Color.BLUE), new ColorPaletteDef.Point(300, Color.RED), new ColorPaletteDef.Point(400, Color.GREEN), }, 7); cpd.setDiscrete(true); final ImageInfo imageInfo = new ImageInfo(cpd); imageInfo.setLogScaled(false); final Color[] palette = ImageManager.createColorPalette(imageInfo); assertNotNull(palette); assertEquals(7, palette.length); assertEquals(new Color(255, 255, 255), palette[0]); assertEquals(new Color(255, 255, 255), palette[1]); assertEquals(new Color(0, 0, 255), palette[2]); assertEquals(new Color(0, 0, 255), palette[3]); assertEquals(new Color(255, 0, 0), palette[4]); assertEquals(new Color(255, 0, 0), palette[4]); assertEquals(new Color(0, 255, 0), palette[6]); }
final ColorPaletteDef gradationCurve = new ColorPaletteDef(min, center, max);
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); }
@Test public void testCreateClone_andEquals() { //preparation final Point[] points = { new Point(1, Color.black), new Point(2, Color.red), new Point(3, Color.green), new Point(4, Color.blue), new Point(5, Color.white), }; final ColorPaletteDef cpd = new ColorPaletteDef(points, 256); cpd.setDiscrete(true); cpd.setAutoDistribute(true); //execution final ColorPaletteDef clone = (ColorPaletteDef) cpd.clone(); //verification assertTrue(cpd.equals(clone)); }
@Test public void testConstructors() { ColorPaletteDef cpd = new ColorPaletteDef(-1.0, 1.0); assertEquals(256, cpd.getNumColors()); assertEquals(3, cpd.getNumPoints()); assertEquals(Color.WHITE, cpd.getPointAt(2).getColor()); cpd = new ColorPaletteDef(-1.0, 0.5, 1.0); assertEquals(256, cpd.getNumColors()); assertEquals(3, cpd.getNumPoints()); assertEquals(Color.WHITE, cpd.getPointAt(2).getColor()); cpd = new ColorPaletteDef(new Point[]{ new Point(100, Color.ORANGE), new Point(200, Color.MAGENTA), cpd = new ColorPaletteDef(new Point[]{ new Point(100, Color.ORANGE), new Point(200, Color.MAGENTA),
Band band2 = product.addBand("b2", "X + Y"); Band band3 = product.addBand("b3", "X + Y"); ImageInfo imageInfo = new ImageInfo(new ColorPaletteDef(new ColorPaletteDef.Point[]{ new ColorPaletteDef.Point(1.0, Color.YELLOW), new ColorPaletteDef.Point(2.0, Color.RED),
public void testImageInfo1Band() { final ColorPaletteDef cpd = new ColorPaletteDef(new ColorPaletteDef.Point[]{ new ColorPaletteDef.Point(100, Color.ORANGE), new ColorPaletteDef.Point(200, Color.MAGENTA), new ColorPaletteDef.Point(500, Color.BLUE), new ColorPaletteDef.Point(600, Color.WHITE) }); ImageInfo imageInfo = new ImageInfo(cpd); assertSame(cpd, imageInfo.getColorPaletteDef()); assertEquals(null, imageInfo.getRgbChannelDef()); assertEquals(4, imageInfo.getColorComponentCount()); assertEquals(ImageInfo.NO_COLOR, imageInfo.getNoDataColor()); assertEquals(ImageInfo.HistogramMatching.None, imageInfo.getHistogramMatching()); assertNotNull(imageInfo.getColors()); assertEquals(4, imageInfo.getColors().length); assertEquals(Color.ORANGE, imageInfo.getColors()[0]); assertEquals(Color.MAGENTA, imageInfo.getColors()[1]); assertEquals(Color.BLUE, imageInfo.getColors()[2]); assertEquals(Color.WHITE, imageInfo.getColors()[3]); imageInfo.setNoDataColor(Color.RED); assertEquals(Color.RED, imageInfo.getNoDataColor()); assertEquals(3, imageInfo.getColorComponentCount()); imageInfo.setHistogramMatching(ImageInfo.HistogramMatching.Equalize); assertEquals(ImageInfo.HistogramMatching.Equalize, imageInfo.getHistogramMatching()); }