下面列出了java.awt.image.renderable.ParameterBlock#getObjectParameter() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/** Creates an BinarizeOpImage with a given ParameterBlock */
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderingHints)
{
RenderedImage img = paramBlock.getRenderedSource(0);
ImageLayout il = new ImageLayout(img);
ColorModel cm = new IndexColorModel(1, 2, bwColors, bwColors, bwColors);
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
img.getWidth(),
img.getHeight(),
1);
il.setColorModel(cm);
il.setSampleModel(sm);
return new BinarizeOpImage(paramBlock.getRenderedSource(0),
renderingHints,
il,
(Integer)paramBlock.getObjectParameter(0));
}
/**
* Creates a new instance of <code>QuicklookOlciOpImage</code> in the
* rendered layer. 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)
{
// Get ImageLayout from renderHints if any.
ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
// Get the number of the sources
int numSources = paramBlock.getNumSources();
// Creation of a source ArrayList (better than a Vector)
List<RenderedImage> sources = new ArrayList<RenderedImage>(numSources);
// Addition of the sources to the List
for (int i = 0; i < numSources; i++)
{
sources.add((RenderedImage)paramBlock.getSource(i));
}
// Extracts parameters
short[][] detectors = (short[][])paramBlock.getObjectParameter(0);
double[][] sza = (double[][])paramBlock.getObjectParameter(1);
float[][] solar_flux = (float[][])paramBlock.getObjectParameter(2);
PixelCorrection[]pc=(PixelCorrection[])paramBlock.getObjectParameter(3);
int[] bands = (int[])paramBlock.getObjectParameter(4);
int[] coefficients = (int[])paramBlock.getObjectParameter(5);
return new QuicklookOlciOpImage(sources, hints, detectors, sza,
solar_flux, pc, bands, coefficients, layout);
}
/**
* Creates a new instance of warp operator according to the warp object and interpolation method.
*
* @param paramBlock The warp and interpolation objects.
*/
@Override
public RenderedImage create(final ParameterBlock paramBlock, final RenderingHints renderHints) {
final Interpolation interp = (Interpolation) paramBlock.getObjectParameter(1);
if ((interp instanceof InterpolationNearest)
|| (interp instanceof javax.media.jai.InterpolationNearest)) {
// Get ImageLayout from renderHints if any.
final ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
RenderedImage source = paramBlock.getRenderedSource(0);
final Warp warp = (Warp) paramBlock.getObjectParameter(0);
final double[] backgroundValues = (double[]) paramBlock.getObjectParameter(2);
ROI roi = null;
final Object roi_ = paramBlock.getObjectParameter(3);
if (roi_ instanceof ROI) {
roi = (ROI) roi_;
final PlanarImage temp = PlanarImage.wrapRenderedImage(source);
temp.setProperty("ROI", roi);
source = temp;
}
Range noData = (Range) paramBlock.getObjectParameter(4);
noData = RangeFactory.convert(noData, source.getSampleModel().getDataType());
return new WarpNearestOpImage(
source,
renderHints,
layout,
warp,
interp,
roi,
noData,
backgroundValues);
}
return super.create(paramBlock, renderHints);
}
/** Creates an RLSAOpImage with a given ParameterBlock */
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderingHints)
{
return new SkeletonOpImage(paramBlock.getRenderedSource(0),
renderingHints,
new ImageLayout(paramBlock.getRenderedSource(0)),
(Boolean) paramBlock.getObjectParameter(0));
}
/** Creates an PowerOpImage with a given ParameterBlock */
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderingHints)
{
return new PowerOpImage(paramBlock.getRenderedSource(0),
renderingHints,
new ImageLayout(paramBlock.getRenderedSource(0)),
(Double) paramBlock.getObjectParameter(0));
}
/** Invokes the operator with a given ParameterBlock */
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderHints)
{
return new CCOpImage(paramBlock.getRenderedSource(0),
(Rectangle) paramBlock.getObjectParameter(0));
}
/** Creates an RLSAOpImage with a given ParameterBlock */
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderHints)
{
return new RLSAOpImage(paramBlock.getRenderedSource(0),
null,
new ImageLayout(paramBlock.getRenderedSource(0)),
(Integer) paramBlock.getObjectParameter(0),
(Integer) paramBlock.getObjectParameter(1));
}
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderHints)
{
if (!validateParameters(paramBlock)) {
return null;
}
return new ProjectionProfileOpImage
(paramBlock.getRenderedSource(0),
(Rectangle) paramBlock.getObjectParameter(0));
}
public boolean validateParameters(ParameterBlock paramBlock) {
Object arg = paramBlock.getObjectParameter(0);
if (arg == null) {
return false;
}
if (!(arg instanceof Rectangle)) {
return false;
}
return true;
}
/** Creates an RandomizeOpImage with a given ParameterBlock */
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderingHints)
{
int width = ((Integer) paramBlock.getObjectParameter(0)).intValue();
int height = ((Integer) paramBlock.getObjectParameter(1)).intValue();
ImageLayout il = new ImageLayout(0, 0, width, height);
int[] bits = { 8 };
ColorModel cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY),
bits, false, false,
Transparency.OPAQUE,
DataBuffer.TYPE_BYTE);
int[] bandoffsets = { 0 };
SampleModel sm = new ComponentSampleModel(DataBuffer.TYPE_BYTE,
width, height, 1, width,
bandoffsets);
il.setColorModel(cm);
il.setSampleModel(sm);
return new RandomizeOpImage(il, renderingHints, (Double) paramBlock.getObjectParameter(2));
}
/**
* Should create a new instance of <code>QuicklookSlstrOpImage</code> in the
* rendered layer.
* 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;
}