Package java.awt.image.renderable

Examples of java.awt.image.renderable.ParameterBlock


            ColorScience.YST yst = new ColorScience.YST();

            double[][] rgb2yst = yst.fromRGB(back.getSampleModel().getDataType());
            double[][] yst2rgb = yst.toRGB(back.getSampleModel().getDataType());

            ParameterBlock pb = new ParameterBlock();
            pb.addSource( back );
            pb.add( rgb2yst );
            RenderedOp ystImage = JAI.create("BandCombine", pb, null);

            pb = new ParameterBlock();
            pb.addSource(ystImage);
            pb.add(new int[]{1, 2});
            RenderedOp cc = JAI.create("bandselect", pb, JAIContext.noCacheHint);

            RenderingHints extenderHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                              BorderExtender.createInstance(BorderExtender.BORDER_COPY));
            pb = new ParameterBlock();
            pb.addSource(LuminanceUSMProcessorInstance.process(back));
            pb.addSource(Functions.gaussianBlur(back, rendering, op, LuminanceUSMProcessorInstance, radius * scale));
            pb.add(amount/100.0);
            pb.add((int) threshold);
            RenderedOp usm = JAI.create("LCUnSharpMask", pb, extenderHints);
            usm.setProperty(JAIContext.PERSISTENT_CACHE_TAG, Boolean.TRUE);

            pb = new ParameterBlock();
            pb.addSource(usm);
            pb.add(getTable());
            RenderedOp invLookup = JAI.create("lookup", pb, JAIContext.noCacheHint);

            RenderingHints layoutHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, Functions.getImageLayout(ystImage));
            pb = new ParameterBlock();
            pb.addSource(invLookup);
            pb.addSource(cc);
            layoutHints.add(JAIContext.noCacheHint);
            RenderedOp denoisedyst = JAI.create("BandMerge", pb, layoutHints);

            pb = new ParameterBlock();
            pb.addSource( denoisedyst );
            pb.add( yst2rgb );
            return JAI.create("BandCombine", pb, JAIContext.noCacheHint);
        }
View Full Code Here


            if (lastBack.get() != back || mask.get() == null || depth != last_radius || fuzz != last_fuzz) {
                RenderedImage singleChannel;
                if (back.getColorModel().getNumComponents() == 3) {
                    double[][] yChannel = new double[][]{{ColorScience.Wr, ColorScience.Wg, ColorScience.Wb, 0}};

                    ParameterBlock pb = new ParameterBlock();
                    pb.addSource( back );
                    pb.add( yChannel );
                    singleChannel = JAI.create("BandCombine", pb, null);
                } else
                    singleChannel = back;

                BorderExtender copyExtender = BorderExtender.createInstance(BorderExtender.BORDER_COPY);
                RenderingHints extenderHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, copyExtender);

                PlanarImage maskImage = new FastBilateralFilterOpImage(singleChannel,
                                                                       JAIContext.fileCacheHint,
                                                                       (float) (depth * scale), 0.1f);

                ParameterBlock pb = new ParameterBlock();
                pb.addSource(maskImage);
                pb.add(new int[]{0});
                maskImage = JAI.create("bandselect", pb, null);

                if (fuzz > 0.1) {
                    KernelJAI kernel = Functions.getGaussKernel(10 * (fuzz - 0.1) * scale);
                    pb = new ParameterBlock();
                    pb.addSource(maskImage);
                    pb.add(kernel);
                    maskImage = JAI.create("LCSeparableConvolve", pb, extenderHints);
                }

                last_radius = fuzz;
                last_fuzz = detail;
View Full Code Here

            for (int i = 0; i < 0x10000; i++)
                table[2][i] = (short) (0xffff & (int) Math.min(Math.max(i + 0xff * interpolator.interpolate(i / (double) 0xffff, blueCurve), 0), 0xffff));

            LookupTableJAI lookupTable = new LookupTableJAI(table, true);

            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add(lookupTable);
            return JAI.create("lookup", pb, null);
        } else
            return image;
    }
View Full Code Here

                RenderedOp rop = (RenderedOp) printImage;
                rop.setRenderingHint(JAI.KEY_TILE_CACHE, JAIContext.defaultTileCache);
            }

            if (fakeLandscape) {
                ParameterBlock params = new ParameterBlock();
                params.addSource(printImage);
                params.add(TransposeDescriptor.ROTATE_90);
                printImage = JAI.create("Transpose", params, null);
            }

            if (printResolution != PRINTER_RESOLUTION) {
                double scale = PRINTER_RESOLUTION / printResolution;

                System.out.println("Uprezzing by " + scale * 100 + '%');

                AffineTransform xform = AffineTransform.getScaleInstance(scale, scale);

                RenderingHints formatHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));

                // Do not recycle these tiles, the canvas will cache them
                // formatHints.add(new RenderingHints(JAI.KEY_CACHED_TILE_RECYCLING_ENABLED, Boolean.FALSE));

                Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BICUBIC_2);
                ParameterBlock params = new ParameterBlock();
                params.addSource(printImage);
                params.add(xform);
                params.add(interp);
                printImage = JAI.create("Affine", params, formatHints);
            }

            if (!printCancelled) {
                System.out.println("print image bounds: " + printImage.getBounds());
View Full Code Here

        public RenderedOp process(RenderedImage source) {
            RenderedImage singleChannel;
            if (source.getColorModel().getNumComponents() == 3) {
                double[][] yChannel = new double[][]{{ColorScience.Wr, ColorScience.Wg, ColorScience.Wb, 0}};

                ParameterBlock pb = new ParameterBlock();
                pb.addSource( source );
                pb.add( yChannel );
                singleChannel = JAI.create("BandCombine", pb, null);
            } else
                singleChannel = source;

            RenderedOp invert = JAI.create("Not", singleChannel, JAIContext.noCacheHint);       // Invert
            LookupTableJAI table = computeGammaTable(invert.getColorModel().getTransferType());
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(invert);
            pb.add(table);
            // we cache this since convolution scans its input multiple times
            return JAI.create("lookup", pb, null);
        }
View Full Code Here

            if (detail > 0) {
                RenderedImage singleChannel;
                if (back.getColorModel().getNumComponents() == 3) {
                    double[][] yChannel = new double[][]{{ColorScience.Wr, ColorScience.Wg, ColorScience.Wb, 0}};

                    ParameterBlock pb = new ParameterBlock();
                    pb.addSource( back );
                    pb.add( yChannel );
                    singleChannel = JAI.create("BandCombine", pb, null);
                } else
                    singleChannel = back;

                ParameterBlock pb = new ParameterBlock();
                pb.addSource( singleChannel );
                pb.add(2f * scale);
                pb.add(20f);
                RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                          BorderExtender.createInstance(BorderExtender.BORDER_COPY));
                RenderedOp bilateral = JAI.create("BilateralFilter", pb, hints);

                pb = new ParameterBlock();
                pb.addSource(bilateral);
                pb.addSource(front);
                pb.add("Overlay");
                pb.add(detail);
                front = JAI.create("Blend", pb, null);
            }

            return front;
        }
View Full Code Here

            super(source);
        }

        public PlanarImage setFront() {
            LookupTableJAI table = computeTable(back);
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(back);
            pb.add(table);

            // Add a layout hint to make sure that source and destination match

            RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT,
                                                      new ImageLayout(back));
View Full Code Here

            PlanarImage scaleDown;
            if (rescale != 1) {
                float scaleX = (float) Math.floor(rescale * back.getWidth()) / (float) back.getWidth();
                float scaleY = (float) Math.floor(rescale * back.getHeight()) / (float) back.getHeight();

                ParameterBlock pb = new ParameterBlock();
                pb.addSource(back);
                pb.add(AffineTransform.getScaleInstance(scaleX, scaleY));
                pb.add(interp);
                RenderingHints layoutHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT,
                                                            new ImageLayout(0, 0,
                                                                            Math.max(JAIContext.TILE_WIDTH/divideByTwo, 8),
                                                                            Math.max(JAIContext.TILE_HEIGHT/divideByTwo, 8),
                                                                            null, null));
                layoutHints.add(hints);
                layoutHints.add(JAIContext.noCacheHint);
                scaleDown = JAI.create("Affine", pb, layoutHints);
            } else
                scaleDown = back;

            if (scaleDown.getColorModel().getNumComponents() == 3) {
                ParameterBlock pb = new ParameterBlock();
                pb.addSource(scaleDown);
                pb.add(transform);
                scaleDown = JAI.create("BandCombine", pb, JAIContext.noCacheHint)// Desaturate, single banded
            }

            scaleDown = JAI.create("Not", scaleDown, JAIContext.noCacheHint);       // Invert
            LookupTableJAI table = computeGammaTable(scaleDown.getSampleModel().getDataType());
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(scaleDown);
            pb.add(table);
            // we cache this since convolution scans its input multiple times
            gammaCurve = JAI.create("lookup", pb, null /*JAIContext.noCacheHint*/);

            kernel = Functions.getGaussKernel(newRadius);
            pb = new ParameterBlock();
            pb.addSource(gammaCurve);
            pb.add(kernel);
            // RenderingHints convolveHints = new RenderingHints(hints);
            // convolveHints.add(JAIContext.noCacheHint);
            RenderedOp blur = JAI.create("LCSeparableConvolve", pb, hints);    // Gaussian Blur

            if (rescale != 1) {
                pb = new ParameterBlock();
                pb.addSource(blur);
                pb.add(AffineTransform.getScaleInstance(back.getWidth() / (double) scaleDown.getWidth(),
                                                        back.getHeight() / (double) scaleDown.getHeight()));
                pb.add(interp);
                RenderingHints resultLayoutHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT,
                                                                  new ImageLayout(0, 0,
                                                                                  JAIContext.TILE_WIDTH,
                                                                                  JAIContext.TILE_HEIGHT,
                                                                                  null, null));
View Full Code Here

        Rectangle bounds = new Rectangle(image.getMinX(), image.getMinY(), image.getWidth(), image.getHeight());

        visibleRect = bounds.intersection(visibleRect);

        if (bounds.contains(visibleRect)) {
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add((float) visibleRect.x);
            pb.add((float) visibleRect.y);
            pb.add((float) visibleRect.width);
            pb.add((float) visibleRect.height);
            image = JAI.create("Crop", pb, JAIContext.noCacheHint);
        }

        Dimension previewSize = getSize();

        if (visibleRect.width > previewSize.width || visibleRect.height > previewSize.height) {
            float scale = Math.min(previewSize.width / (float) visibleRect.width, previewSize.height / (float) visibleRect.height);

            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add(scale);
            pb.add(scale);
            image = JAI.create("Scale", pb, JAIContext.noCacheHint);
        }

        image = Functions.toColorSpace(image, JAIContext.systemColorSpace, null);
View Full Code Here

                for (int i = 0; i < 0x10000; i++)
                    table[2][i] = (short) (0xffff & (int) Math.min(Math.max(i + 0xff * interpolator.interpolate(i / (double) 0xffff, blueCurve), 0), 0xffff));

                LookupTableJAI lookupTable = new LookupTableJAI(table, true);

                ParameterBlock pb = new ParameterBlock();
                pb.addSource(back);
                pb.add(lookupTable);
                return JAI.create("lookup", pb, JAIContext.noCacheHint);
            } else {
                return back;
            }
        }
View Full Code Here

TOP

Related Classes of java.awt.image.renderable.ParameterBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.