List of usage examples for java.awt.image.renderable ParameterBlock getSource
public Object getSource(int index)
From source file:fr.gael.drb.cortex.topic.sentinel3.jai.operator.QuicklookSlstrRIF.java
/** * Should create a new instance of <code>QuicklookSlstrOpImage</code> in the * rendered layer./*from w ww. ja va 2 s .co m*/ * This operator could be called by chunks of images. * A set of additional information are required to compute the pixels * adjustment such as sun azimuth/elevation and detectors... The methods to * extract these informations are also provided here before. * * @param paramBlock The three R/G/B sources images to be "Merged" together * to produce the Quicklook. * @param renderHints Optionally contains destination image layout. */ public RenderedImage create(ParameterBlock paramBlock, RenderingHints hints) { long start = System.currentTimeMillis(); RenderedImage computed_image = null; DrbImage red = (DrbImage) paramBlock.getSource(4); // S5 DrbImage green = (DrbImage) paramBlock.getSource(2); // S3 DrbImage blue = (DrbImage) paramBlock.getSource(1); // S2 PixelCorrection[] pc = (PixelCorrection[]) paramBlock.getObjectParameter(0); PixelCorrection red_correction = pc != null ? pc[0] : null; PixelCorrection green_correction = pc != null ? pc[1] : null; PixelCorrection blue_correction = pc != null ? pc[2] : null; try { computed_image = naturalColors(red.getData(), red_correction, green.getData(), green_correction, blue.getData(), blue_correction); } catch (Exception e) { // Image access problem: try to reprocess this other bands LOGGER.info("Natural color band looks bad. Trying S8..."); DrbImage image = (DrbImage) paramBlock.getSource(7); // S8 PixelCorrection corr = pc != null ? pc[3] : null; try { computed_image = grayScaleBand(image.getData(), corr, true); } catch (Exception e1) { // S8 also bad band: try with S9... LOGGER.info("Thermal band S8 looks bad. Trying S9..."); image = (DrbImage) paramBlock.getSource(8); // S9 corr = pc != null ? pc[4] : null; try { computed_image = grayScaleBand(image.getData(), corr, false); } catch (Exception e2) { throw new UnsupportedOperationException("Image cannot be processed (" + e1.getMessage() + ").", e2); } } } LOGGER.info("Quicklook generated in " + (System.currentTimeMillis() - start) / 1000 + " secs"); return computed_image; }