/** * Update the gamma value * * @param g * new gamma value */ public void setGamma( double g ) { if ( gamma != g ) gammaTable = createGammaTable( g ); gamma = g; }
/** * Construct an image map, as the result of the Categorize operation * * @param raster * input raster * @param style * raster style, that contains channel mappings (if applicable) * @return a buffered image with the processed data */ public BufferedImage evaluateRaster( AbstractRaster raster, RasterStyling style ) { BufferedImage img = null; int col = -1, row = -1; RasterData data = raster.getAsSimpleRaster().getRasterData(); RasterDataUtility converter = new RasterDataUtility( raster, style.channelSelection ); img = new BufferedImage( data.getColumns(), data.getRows(), BufferedImage.TYPE_INT_ARGB ); LOG.trace( "Created image with H={}, L={}", img.getHeight(), img.getWidth() ); for ( row = 0; row < img.getHeight(); row++ ) { for ( col = 0; col < img.getWidth(); col++ ) { Color c = lookup2( converter.get( col, row ) ); img.setRGB( col, row, c.getRGB() ); } } return img; }
/** * Performs contrast enhancement on all bands of a raster and returns the modified raster. * * @param raster * initial raster * @param contrastEnhancement * @return the enhanced raster */ private AbstractRaster performContrastEnhancement( AbstractRaster raster, ContrastEnhancement contrastEnhancement ) { if ( contrastEnhancement == null ) return raster; LOG.trace( "Enhancing contrast for overall raster..." ); RasterData data = raster.getAsSimpleRaster().getRasterData(), newData = data; RasterDataUtility rasutil = new RasterDataUtility( raster ); rasutil.setContrastEnhancement( contrastEnhancement ); rasutil.precomputeContrastEnhancements( -1, contrastEnhancement ); for ( int band = 0; band < data.getBands(); band++ ) newData = setEnhancedChannelData( newData, rasutil, band, band, contrastEnhancement ); AbstractRaster newRaster = new SimpleRaster( newData, raster.getEnvelope(), raster.getRasterReference(), null ); return newRaster; }
ret = combineBytes( data.getBytePixel( col, row, null ) ); case SHORT: case USHORT: ret = combineShorts( data.getShortPixel( col, row, null ) ); break; case INT: ret = combineInts( data.getIntPixel( col, row, null ) ); break; case FLOAT: ret = combineFloats( data.getFloatPixel( col, row, null ) ); break; default:
int redIndex = idx[0], greenIndex = idx[1]; int blueIndex = idx[2], grayIndex = idx[3]; RasterDataUtility rasutil = new RasterDataUtility( raster, channels ); RasterData newData = simpleRaster.getRasterData(); BandType[] bandTypes = null; data.getDataInfo().interleaveType, false ); rasutil.precomputeContrastEnhancements( redIndex, channels.channelContrastEnhancements.get( "red" ) ); newData = setEnhancedChannelData( newData, rasutil, redIndex, 0, channels.channelContrastEnhancements.get( "red" ) ); rasutil.precomputeContrastEnhancements( greenIndex, channels.channelContrastEnhancements.get( "green" ) ); newData = setEnhancedChannelData( newData, rasutil, greenIndex, 1, channels.channelContrastEnhancements.get( "green" ) ); rasutil.precomputeContrastEnhancements( blueIndex, channels.channelContrastEnhancements.get( "blue" ) ); newData = setEnhancedChannelData( newData, rasutil, blueIndex, 2, channels.channelContrastEnhancements.get( "blue" ) );
/** * Perform contrast enhancement on one channel and copy the result to a RasterData object. * * @param newData * RasterData output container * @param rasutil * channel data source * @param inIndex * input channel index * @param outIndex * output channel index * @param enhancement * ContrastEnhancement to perform * @return modified RasterData container */ private RasterData setEnhancedChannelData( RasterData newData, RasterDataUtility rasutil, int inIndex, int outIndex, ContrastEnhancement enhancement ) { int i = 0, j = 0, val = 0, cols = newData.getColumns(), rows = newData.getRows(); rasutil.setContrastEnhancement( enhancement ); if ( enhancement != null ) { LOG.trace( "Using gamma {} for channel '{}'...", enhancement.gamma, inIndex ); } for ( i = 0; i < cols; i++ ) for ( j = 0; j < rows; j++ ) { val = (int) rasutil.getEnhanced( i, j, inIndex ); newData.setByteSample( i, j, outIndex, int2byte( val ) ); } return newData; }
/** * Construct an image map, as the result of the Interpolate operation * * @param raster * input raster * @param style * raster style, containing channel mappings (if applicable) * @return a buffered image with the processed data */ public BufferedImage evaluateRaster( AbstractRaster raster, RasterStyling style ) { BufferedImage img = null; int col = -1, row = -1; int rgb = 0; RasterData data = raster.getAsSimpleRaster().getRasterData(); RasterDataUtility rawData = new RasterDataUtility( raster ); img = new BufferedImage( data.getColumns(), data.getRows(), BufferedImage.TYPE_INT_ARGB ); LOG.debug( "Created image with H={}, L={}", img.getHeight(), img.getWidth() ); for ( row = 0; row < img.getHeight(); row++ ) for ( col = 0; col < img.getWidth(); col++ ) { float val = rawData.get( col, row ); rgb = lookup2Color( val ).getRGB(); img.setRGB( col, row, rgb ); } return img; }
RasterDataUtility data = new RasterDataUtility( raster, style.channelSelection ); RasterData shadeData = RasterDataFactory.createRasterData( cols - 2, rows - 2, DataType.BYTE, false ); RasterGeoReference ref = raster.getRasterReference(); m[0][0] = data.get( col - 1, row - 1 ); m[0][1] = data.get( col, row - 1 ); m[0][2] = data.get( col + 1, row - 1 ); m[1][0] = data.get( col - 1, row ); m[1][1] = data.get( col, row ); m[1][2] = data.get( col + 1, row ); m[2][0] = data.get( col - 1, row + 1 ); m[2][1] = data.get( col, row + 1 ); m[2][2] = data.get( col + 1, row + 1 );