java.awt.image.renderable.ParameterBlock Java Examples
The following examples show how to use
java.awt.image.renderable.ParameterBlock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OrbitTiledImage2.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
private PlanarImage convertColorModel(PlanarImage pi) { int numComponents = pi.getColorModel().getNumComponents(); boolean isGrey = numComponents == 1; ColorModel colorModel = rgbColorModel; if (isGrey) colorModel = grayColorModel; try { ParameterBlock pb = new ParameterBlock(); pb.addSource(pi).add(colorModel); RenderedOp dst = JAI.create("ColorConvert", pb); return dst.getRendering(); } catch (IllegalArgumentException ex) { logger.info("Error: Cannot convert color model. Original color model: " + pi.getColorModel()); return null; } }
Example #2
Source File: BinarizeDescriptor.java From pdfxtk with Apache License 2.0 | 6 votes |
/** 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)); }
Example #3
Source File: OrbitTiledImage2.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
public static PlanarImage adjustBrightness(PlanarImage src, final double b) { final double[][] matrixRGB = { {1d, 0D, 0D, b}, {0D, 1d, 0D, b}, {0, 0D, 1d, b} }; final double[][] matrixGrey = { {1d, b} }; double[][] matrix; if (src.getSampleModel().getNumBands() > 1) matrix = matrixRGB; else matrix = matrixGrey; ParameterBlock pb = new ParameterBlock(); pb.addSource(src); pb.add(matrix); return JAI.create("bandcombine", pb); }
Example #4
Source File: MosaicPropertyGenerator.java From geowave with Apache License 2.0 | 6 votes |
@Override public Object getProperty(final String name, final Object opNode) { validate(name, opNode); if ((opNode instanceof RenderedOp) && name.equalsIgnoreCase("sourceThreshold")) { final RenderedOp op = (RenderedOp) opNode; final ParameterBlock pb = op.getParameterBlock(); // Retrieve the rendered source image and its ROI. final RenderedImage src = pb.getRenderedSource(0); final Object property = src.getProperty("sourceThreshold"); if (property != null) { return property; } // Getting the Threshold to use final double threshold = CoverageUtilities.getMosaicThreshold(src.getSampleModel().getDataType()); // Setting the Threshold object for the mosaic return new double[][] {{threshold}}; } return java.awt.Image.UndefinedProperty; }
Example #5
Source File: BlackOrDescriptor.java From pdfxtk with Apache License 2.0 | 5 votes |
/** Creates a BlackOrOpImage with a given ParameterBlock */ public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderingHints) { return new BlackOrOpImage(paramBlock.getRenderedSource(0), paramBlock.getRenderedSource(1), new ImageLayout(paramBlock.getRenderedSource(0)), renderingHints, true); }
Example #6
Source File: Picture.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
public static PlanarImage invert (RenderedImage image) { return JAI.create( "Invert", new ParameterBlock().addSource(image).add(null), null); }
Example #7
Source File: JaiDewarper.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
public RenderedImage dewarpImage () { ParameterBlock pb = new ParameterBlock(); pb.addSource(Picture.invert(sheet.getPicture().getImage())); pb.add(dewarpGrid); pb.add(new InterpolationBilinear()); RenderedImage dewarpedImage = Picture.invert(JAI.create("warp", pb)); ((PlanarImage) dewarpedImage).getTiles(); return dewarpedImage; }
Example #8
Source File: TestWarp.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates a new TestWarp object. */ public TestWarp (String path) { srcImage = JAI.create("fileload", new ParameterBlock().add(path), null); // srcImage = PictureLoader.loadImages(new File(path), null) // .get(1); // srcImage = buildPattern(20, 10, 50, 50); dimension = new Dimension(srcImage.getWidth(), srcImage.getHeight()); setPreferredSize(dimension); // float[] xCoeffs = new float[] { 0f, 1.25f, 0.04f }; // float[] yCoeffs = new float[] { 0f, -0.02f, 1.5f }; // Warp warp = new WarpAffine(xCoeffs, yCoeffs); // int xStep = 500; int xNumCells = 2; int yStep = 500; int yNumCells = 1; float[] warpPositions = new float[] { -100f, 0f, 500f, 100f, 1000f, 0f, // top line 0f, 500f, 500f, 500f, 1000f, 500f }; // bot line Warp warp = new WarpGrid( 0, xStep, xNumCells, 0, yStep, yNumCells, warpPositions); ParameterBlock pb = new ParameterBlock(); pb.addSource(invert(srcImage)); pb.add(warp); pb.add(new InterpolationBilinear()); dstImage = invert(JAI.create("warp", pb)); ((PlanarImage) dstImage).getTiles(); }
Example #9
Source File: TestWarp.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
private static RenderedImage invert (RenderedImage image) { return JAI.create( "Invert", new ParameterBlock().addSource(image).add(null).add(null).add(null).add( null).add(null), null); }
Example #10
Source File: TestImage3.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
private static PlanarImage invert (PlanarImage image) { return JAI.create("Invert", new ParameterBlock() .addSource(image) .add(null) .add(null) .add(null) .add(null) .add(null), null); }
Example #11
Source File: TestImage3.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
private static PlanarImage colorToGray (PlanarImage image) { System.out.println("Converting color image to gray ..."); double[][] matrix = { {0.114d, 0.587d, 0.299d, 0.0d} }; return JAI.create("bandcombine", new ParameterBlock() .addSource(image) .add(matrix), null); }
Example #12
Source File: WarpRIF.java From geowave with Apache License 2.0 | 5 votes |
/** * 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); }
Example #13
Source File: SkeletonDescriptor.java From pdfxtk with Apache License 2.0 | 5 votes |
/** 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)); }
Example #14
Source File: ImageUtil.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Take an RGB image and combine the R,G and B bands according to standard luminance * value to provide the output gray value. * * @param rgb input image with 3 bands RGB * @return a gray image */ public static BufferedImage rgbToGray (BufferedImage rgb) { logger.info("Converting RGB to gray ..."); // We use luminance value based on standard RGB combination double[][] matrix = {{0.114d, 0.587d, 0.299d, 0.0d}}; return JAI.create("bandcombine", new ParameterBlock().addSource(rgb).add(matrix), null) .getAsBufferedImage(); }
Example #15
Source File: PowerDescriptor.java From pdfxtk with Apache License 2.0 | 5 votes |
/** 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)); }
Example #16
Source File: CCDescriptor.java From pdfxtk with Apache License 2.0 | 5 votes |
/** Invokes the operator with a given ParameterBlock */ public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) { return new CCOpImage(paramBlock.getRenderedSource(0), (Rectangle) paramBlock.getObjectParameter(0)); }
Example #17
Source File: RLSADescriptor.java From pdfxtk with Apache License 2.0 | 5 votes |
/** 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)); }
Example #18
Source File: ProjectionProfileDescriptor.java From pdfxtk with Apache License 2.0 | 5 votes |
public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) { if (!validateParameters(paramBlock)) { return null; } return new ProjectionProfileOpImage (paramBlock.getRenderedSource(0), (Rectangle) paramBlock.getObjectParameter(0)); }
Example #19
Source File: ProjectionProfileDescriptor.java From pdfxtk with Apache License 2.0 | 5 votes |
public boolean validateParameters(ParameterBlock paramBlock) { Object arg = paramBlock.getObjectParameter(0); if (arg == null) { return false; } if (!(arg instanceof Rectangle)) { return false; } return true; }
Example #20
Source File: RandomizeDescriptor.java From pdfxtk with Apache License 2.0 | 5 votes |
/** 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)); }
Example #21
Source File: ImageUtils.java From gama with GNU General Public License v3.0 | 5 votes |
private BufferedImage privateReadFromFile(final File file, final boolean forOpenGL) throws IOException { // DEBUG.OUT("READING " + file.getName()); BufferedImage result = getNoImage(); if (file == null) { return result; } final String name = file.getName(); String ext = null; if (name.contains(".")) { ext = name.substring(file.getName().lastIndexOf('.')); } if (tiffExt.contains(ext)) { try (FileSeekableStream stream = new FileSeekableStream(file.getAbsolutePath())) { /** * AD TODO : decodeParam is not used ... */ // final TIFFDecodeParam decodeParam = new TIFFDecodeParam(); // decodeParam.setDecodePaletteAsShorts(true); final ParameterBlock params = new ParameterBlock(); params.add(stream); final RenderedOp image1 = JAI.create("tiff", params); return image1.getAsBufferedImage(); } } else if (gifExt.contains(ext)) { final GifDecoder d = new GifDecoder(); d.read(new FileInputStream(file.getAbsolutePath())); return d.getImage(); } try { result = forOpenGL ? ImageIO.read(file) : toCompatibleImage(ImageIO.read(file)); } catch (final Exception e) { return getNoImage(); } return result; }
Example #22
Source File: ProcessingUtils.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
public static RenderedImage resizeImage(RenderedImage image, int width, int height) throws InconsistentImageScale { RenderedImage resizedImage=image; // Computes ratio and scale float scale=getScale(image.getWidth(),image.getHeight(),width,height); // Processing resize process ParameterBlock pb = new ParameterBlock(); // The source image pb.addSource(resizedImage); // The xScale pb.add(scale); // The yScale pb.add(scale); // The x translation pb.add(0.0F); // The y translation pb.add(0.0F); // The interpolation pb.add(Interpolation.getInstance(Interpolation.INTERP_BICUBIC)); resizedImage = JAI.create("scale", pb, null); LOGGER.debug("Image resized to : " + resizedImage.getWidth() + "x" + resizedImage.getHeight()); return resizedImage; }
Example #23
Source File: QuicklookOlciRIF.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
/** * 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); }
Example #24
Source File: MedianFilter.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
public PlanarImage process() { if (!parameterSet) throw new IllegalStateException("parameters not set"); PlanarImage pi = source; // for (int i=0; i<numIter; i++) { ParameterBlock pb = new ParameterBlock(); pb.addSource(pi); pb.add(MedianFilterDescriptor.MEDIAN_MASK_SQUARE); pb.add(radius); pi = JAI.create("MedianFilter", pb); // } return pi; }
Example #25
Source File: ImageTiler.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
private PlanarImage makeTiledImage(PlanarImage img, int tileWidth, int tileHeight) { ImageLayout tileLayout = new ImageLayout(img); tileLayout.setTileWidth(tileWidth); tileLayout.setTileHeight(tileHeight); tileLayout.setSampleModel(img.getColorModel().createCompatibleSampleModel(tileWidth,tileHeight)); tileLayout.setColorModel(img.getColorModel()); RenderingHints tileHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, tileLayout); ParameterBlock pb = new ParameterBlock(); pb.addSource(img); PlanarImage pi = JAI.create("format", pb, tileHints); pi.getWidth(); return pi; }
Example #26
Source File: OrbitTiledImage2.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
private PlanarImage activeChannels(PlanarImage source, boolean redActive, boolean greenActive, boolean blueActive) { final double[][] matrix = { {redActive ? 1D : 0D, 0D, 0D, 0d}, {0D, greenActive ? 1D : 0D, 0D, 0d}, {0D, 0D, blueActive ? 1D : 0D, 0d} }; ParameterBlock pb = new ParameterBlock(); pb.addSource(source); pb.add(matrix); return JAI.create("bandcombine", pb, null); }
Example #27
Source File: ImageCompareUtil.java From qaf with MIT License | 5 votes |
private RenderedImage rescale(RenderedImage i) { float scaleW = ((float) baseSize) / i.getWidth(); float scaleH = ((float) baseSize) / i.getHeight(); // Scales the original image ParameterBlock pb = new ParameterBlock(); pb.addSource(i); pb.add(scaleW); pb.add(scaleH); pb.add(0.0F); pb.add(0.0F); pb.add(new InterpolationNearest()); // Creates a new, scaled image and uses it on the DisplayJAI component return JAI.create("scale", pb); }
Example #28
Source File: OrbitTiledImage2.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
private RenderedOp convertColorToGray(PlanarImage src, double r, double g, double b) { final double[][] matrix = { {r, g, b, 0d} // .114D, 0.587D, 0.299D }; ParameterBlock pb = new ParameterBlock(); pb.addSource(src); pb.add(matrix); return JAI.create("bandcombine", pb, /*ManipulationUtils.getRenderingHints(image)*/null); }
Example #29
Source File: TiledImagePainter.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
public void loadImageSpecial(RawDataFile rdf, int level) throws OrbitImageServletException, SQLException { int num = level; if (num < 1000) num++; // +1 because orbit file system starts with 1 and not 0 (id, id.1, id.2, ...) - but not for special layers like slide overview or label (>=1000) origImage = null; try { switch (level) { case RawUtilsCommon.LEVEL_LABEL: { origImage = new OrbitTiledImagePlanarImage(PlanarImage.wrapRenderedImage(DALConfig.getImageProvider().getLabelImage(rdf))); break; } case RawUtilsCommon.LEVEL_OVERVIEW: { origImage = new OrbitTiledImagePlanarImage(PlanarImage.wrapRenderedImage(DALConfig.getImageProvider().getOverviewImage(rdf))); break; } default: { origImage = new OrbitTiledImageIOrbitImage(wrapImage(DALConfig.getImageProvider().createOrbitImage(rdf, level))); break; } } if (origImage == null) return; // not available if (level == RawUtilsCommon.LEVEL_LABEL) { float centerX = (float) origImage.getWidth() / 2; float centerY = (float) origImage.getHeight() / 2; ParameterBlock pb = new ParameterBlock(); pb.addSource(origImage); pb.add(centerX); pb.add(centerY); pb.add(new Float(Math.toRadians(90))); pb.add(new javax.media.jai.InterpolationBicubic(10)); origImage = JAI.create("rotate", pb); } setImage(origImage); imageName = rdf.toString(); imageAdjustments = OrbitUtils.getAndParseImageAdjustments(rdf.getRawDataFileId()); } catch (Exception e) { logger.error("Special layer not available for this image."); } }
Example #30
Source File: OrbitTiledImage2.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
private RenderedOp convertColorToGray(PlanarImage src) { final double[][] matrix = { // { 0.114D, 0.587D, 0.299D, 0d } // .114D, 0.587D, 0.299D {0.333D, 0.333D, 0.333D, 0d} // .114D, 0.587D, 0.299D }; ParameterBlock pb = new ParameterBlock(); pb.addSource(src); pb.add(matrix); return JAI.create("bandcombine", pb, /*ManipulationUtils.getRenderingHints(image)*/null); }