use of java.awt.image.renderable.ParameterBlock in project vcell by virtualcell.
the class VFrap_OverlayImageDisplayJAI method makeAlpha.
/**
* Method makeAlpha.
* @param src RenderedImage
* @param b float
* @return RenderedImage
*/
private RenderedImage makeAlpha(RenderedImage src, float b) {
// get color band
int band = src.getColorModel().getNumColorComponents();
// ignore alpha channel
band = band > 3 ? 3 : band;
// make alpha channel paramenter
Byte[] bandValues = new Byte[band];
for (int i = 0; i < band; i++) {
bandValues[i] = new Byte((byte) (b * SCALE_MAX));
}
// make alpha channel paramenter
ParameterBlock pb = new ParameterBlock();
pb.add((float) src.getWidth());
pb.add((float) src.getHeight());
pb.add(bandValues);
// make alpha channel
return JAI.create("constant", pb, null);
}
use of java.awt.image.renderable.ParameterBlock in project imageio-ext by geosolutions-it.
the class JP2KakaduReadTest method displayStatistics.
public static void displayStatistics(boolean b, RenderedImage source) {
PlanarImage img = JAI.create("extrema", source, null);
double[] maximum = (double[]) img.getProperty("maximum");
double[] minimum = (double[]) img.getProperty("minimum");
ParameterBlock pb = (new ParameterBlock()).addSource(source);
pb.add(null).add(1).add(1).add(new int[] { 65536 });
pb.add(new double[] { minimum[0] }).add(new double[] { maximum[0] });
PlanarImage dst = JAI.create("histogram", pb);
Histogram h = (Histogram) dst.getProperty("hiStOgRam");
JFrame frame = new HistogramFrame(h, b);
frame.pack();
frame.show();
}
use of java.awt.image.renderable.ParameterBlock in project imageio-ext by geosolutions-it.
the class ImageIOUtilities method visualizeRescaled.
/**
* Visualize the image, after rescaling its values, given a threshold for
* the ROI. This is useful to rescale an image coming from a source which
* may contain noDataValues. The ROI threshold allows to set a minimal value
* to be included in the computation of the future JAI extrema operation
* used before the JAI rescale operation.
*
* @param image
* RenderedImage to visualize
* @param title
* title for the frame
* @param roiThreshold
* the threshold for the inner ROI
*/
static void visualizeRescaled(RenderedImage image, String title, int roiThreshold) {
ROI roi = new ROI(image, roiThreshold);
ParameterBlock pb = new ParameterBlock();
// The source image
pb.addSource(image);
if (roi != null)
// The region of the image to scan
pb.add(roi);
// Perform the extrema operation on the source image
RenderedOp op = JAI.create("extrema", pb);
// Retrieve both the maximum and minimum pixel value
double[][] extrema = (double[][]) op.getProperty("extrema");
final double[] scale = new double[] { (255) / (extrema[1][0] - extrema[0][0]) };
final double[] offset = new double[] { ((255) * extrema[0][0]) / (extrema[0][0] - extrema[1][0]) };
// Preparing to rescaling values
ParameterBlock pbRescale = new ParameterBlock();
pbRescale.add(scale);
pbRescale.add(offset);
pbRescale.addSource(image);
RenderedOp rescaledImage = JAI.create("Rescale", pbRescale);
ParameterBlock pbConvert = new ParameterBlock();
pbConvert.addSource(rescaledImage);
pbConvert.add(DataBuffer.TYPE_BYTE);
RenderedOp destImage = JAI.create("format", pbConvert);
visualize(destImage, title);
}
use of java.awt.image.renderable.ParameterBlock in project imageio-ext by geosolutions-it.
the class ImageReadPropertyGenerator method create.
/**
* Type-safe convenience method for creating a {@link RenderedOp}
* representing the "ImageRead" operation in rendered mode. The
* method packs the parameters into a new <code>ParameterBlock</code>
* and invokes {@link JAI#create(String,ParameterBlock,RenderingHints)}.
*
* @param input The input source.
* @param imageChoice The index of the image to read.
* @param readMetadata Whether metadata should be read if available.
* @param readThumbnails Whether thumbnails should be read if available.
* @param verifyInput Whether to verify the validity of the input source.
* @param listeners EventListeners to be registered with the ImageReader.
* @param locale The Locale for the ImageReader to use.
* @param readParam Java Image I/O read parameter instance.
* @param reader Java Image I/O reader instance.
* @param hints Hints possibly including an <code>ImageLayout</code>.
* @return an image derived from the input source.
*/
public static RenderedOp create(ImageInputStream input, Integer imageChoice, Boolean readMetadata, Boolean readThumbnails, Boolean verifyInput, EventListener[] listeners, Locale locale, EnhancedImageReadParam readParam, ImageReader reader, RenderingHints hints) {
ParameterBlock args = new ParameterBlock();
args.add(input);
args.add(imageChoice);
args.add(readMetadata);
args.add(readThumbnails);
args.add(verifyInput);
args.add(listeners);
args.add(locale);
args.add(readParam);
args.add(reader);
return JAI.create(OPERATION_NAME, args, hints);
}
use of java.awt.image.renderable.ParameterBlock in project imageio-ext by geosolutions-it.
the class ImageReadPropertyGenerator method createRenderable.
/**
* Type-safe convenience method for creating a {@link RenderableOp}
* representing the "ImageRead" operation in renderable mode. The
* method packs the parameters into a new <code>ParameterBlock</code>
* and invokes
* {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
*
* @param input The input source.
* @param imageChoice The indices of the images to read.
* @param readMetadata Whether metadata should be read if available.
* @param readThumbnails Whether thumbnails should be read if available.
* @param verifyInput Whether to verify the validity of the input source.
* @param listeners EventListeners to be registered with the ImageReader.
* @param locale The Locale for the ImageReader to use.
* @param readParam Java Image I/O read parameter instance.
* @param reader Java Image I/O reader instance.
* @param hints Hints possibly including an <code>ImageLayout</code>.
* @return an image capable of rendering an image from those in the
* input source.
*/
public static RenderableOp createRenderable(ImageInputStream input, int[] imageChoice, Boolean readMetadata, Boolean readThumbnails, Boolean verifyInput, EventListener[] listeners, Locale locale, ImageReadParam readParam, ImageReader reader, RenderingHints hints) {
ParameterBlock args = new ParameterBlock();
args.add(input);
args.add(imageChoice);
args.add(readMetadata);
args.add(readThumbnails);
args.add(verifyInput);
args.add(listeners);
args.add(locale);
args.add(readParam);
args.add(reader);
return JAI.createRenderable(OPERATION_NAME, args, hints);
}
Aggregations