Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.PlanarImage


                                 int computeType) {
        super(source, layout, configuration, computeType);
    }

    public synchronized void dispose() {
        PlanarImage src = getSource(0);
        if(src instanceof RenderedImageAdapter) {
            // Use relection to invoke dispose();
            RenderedImage trueSrc =
                ((RenderedImageAdapter)src).getWrappedImage();
            Method disposeMethod = null;
            try {
                Class cls = trueSrc.getClass();
                disposeMethod = cls.getMethod("dispose", null);
                if(!disposeMethod.isAccessible()) {
                    AccessibleObject.setAccessible(new AccessibleObject[] {
                        disposeMethod
                    }, true);
                }
                disposeMethod.invoke(trueSrc, null);
            } catch(Exception e) {
                // Ignore it.
            }
        } else {
            // Invoke dispose() directly.
            src.dispose();
        }
    }
View Full Code Here


           SerializableState srcInvalidRegion,
           Object oldRendering)
  throws RemoteException {

  RenderedOp op = (RenderedOp)nodes.get(renderedOpID);
  PlanarImage rendering = op.getRendering();

  // Get a new unique ID
  Long id = getRemoteID();
  // Cache the old rendering against the new id
  nodes.put(id, rendering);

  // Put the op's negotiated result values for its rendering too.
  setServerNegotiatedValues(id, (NegotiableCapabilitySet)
          negotiated.get(renderedOpID));

  PlanarImage oldSrcRendering = null, newSrcRendering = null;
  String serverNodeDesc = null;
  Object src = null;

  if (oldRendering instanceof String) {
View Full Code Here

                                             (int) (settings.getHeight() * resolution.getHeight() / 72.0));

        double xMagnification = targetSize.getWidth() / naturalSize.getWidth();
        double yMagnification = targetSize.getHeight() / naturalSize.getHeight();

        PlanarImage printImage = engine.getRendering(new Dimension((int) (naturalSize.width * (xMagnification < 1 ? xMagnification : 1)),
                                                                   (int) (naturalSize.height * (yMagnification < 1 ? yMagnification : 1))),
                                             settings.getColorProfile() != null
                                             ? settings.getColorProfile()
                                             : JAIContext.sRGBColorProfile,
                                             engine.getLCMSIntent(settings.getRenderingIntent()),
View Full Code Here

     * @param dst      The destination image to be tested.
     * @param dstRect  The rectangle of interest within dst.
     */
    public static void testOpImage(OpImage dst, Rectangle dstRect) {
        for (int i = 0; i < dst.getNumSources(); i++) {
            PlanarImage src = dst.getSourceImage(i);
            Rectangle srcRect = dst.mapDestRect(dstRect, i);
            String message = "Source " + (i+1) + ":";
            printPixels(message, src, srcRect);
        }
        printPixels("Dest:", dst, dstRect);
View Full Code Here

            RenderedOp op = (RenderedOp)opNode;

            ParameterBlock pb = op.getParameterBlock();

            // Retrieve the rendered source image and its ROI.
            PlanarImage src = (PlanarImage)pb.getRenderedSource(0);
            Object roiProperty = src.getProperty("ROI");
            if(roiProperty == null ||
               roiProperty == java.awt.Image.UndefinedProperty ||
               !(roiProperty instanceof ROI)) {
                return java.awt.Image.UndefinedProperty;
            }
            ROI roi = (ROI)roiProperty;

            // Determine the effective destination bounds.
            Rectangle dstBounds = null;
            PlanarImage dst = op.getRendering();
            if(dst instanceof AreaOpImage &&
               ((AreaOpImage)dst).getBorderExtender() == null) {
                AreaOpImage aoi = (AreaOpImage)dst;
                dstBounds =
                    new Rectangle(aoi.getMinX() + aoi.getLeftPadding(),
                                  aoi.getMinY() + aoi.getTopPadding(),
                                  aoi.getWidth() -
                                  aoi.getLeftPadding() -
                                  aoi.getRightPadding(),
                                  aoi.getHeight() -
                                  aoi.getTopPadding() -
                                  aoi.getBottomPadding());
            } else {
                dstBounds = dst.getBounds();
            }

            // If necessary, clip the ROI to the destination bounds.
            // XXX Is this desirable?
            if(!dstBounds.contains(roi.getBounds())) {
View Full Code Here

        ImageLayout layout = new ImageLayout();
        layout.setTileWidth(64);
        layout.setTileHeight(64);
        layout.setColorModel(OpImageTester.createComponentColorModel());

        PlanarImage image =
            new RandomOpImage(0, 0, 100, 100,
                              RasterFactory.createPixelInterleavedSampleModel(
                                              DataBuffer.TYPE_BYTE, 64, 64, 3),
                              null, layout);
View Full Code Here

        RawAdjustments(PlanarImage source) {
            super(source);
        }

        public PlanarImage setFront() {
            PlanarImage front = back;

            /*** WHITE BALANCE and EXPOSURE ***/

            float lightness = 0.18f;

            if (autoWB) {
                float wb[] = autoWhiteBalance(back);
                System.out.println("Auto WB: " + wb[0] + ", " + wb[1] + ", " + wb[2]);

                temperature = neutralTemperature(wb, daylightTemperature);
                tint = 0;

                System.out.println("Correlated Temperature: " + temperature);
            } else if (p != null) {
                int pixel[] = pointToPixel(p);

                if (pixel != null) {
                    float oldTemperature = 0;

                    for (int k = 0; k < 10 && Math.abs(oldTemperature - temperature) > 0.01 * temperature; k++) {
                        oldTemperature = temperature;
                       
                        int newPixel[] = new int[3];
                        for (int i = 0; i < 3; i++)
                            for (int j = 0; j < 3; j++)
                                newPixel[j] += (int) (pixel[i] * cameraRGB(temperature)[j][i]);

                        float n[] = WhiteBalanceV2.neutralize(newPixel, caMethod, temperature, daylightTemperature);

                        lightness = newPixel[1]/255.0f;

                        temperature = n[0];
                        tint = Math.min(Math.max(n[1], -20), 20);
                    }
                }
            }

            // Chromatic adaptation matrix
            Matrix B = new Matrix(ColorScience.chromaticAdaptation(daylightTemperature, temperature, caMethod));
            Matrix CA = XYZtoRGB.times(B.times(RGBtoZYX));

            // Normalize the CA matrix to keep exposure constant
            Matrix m = CA.times(new Matrix(new double[][]{{1},{1},{1}}));
            double max = m.get(1, 0);
            if (max != 1)
                CA = CA.times(new Matrix(new double[][]{{1/max, 0, 0},{0, 1/max, 0},{0, 0, 1/max}}));

            float actualExposure = exposure;
            String thisCamera = metadata.getCameraMake(true);
            for (String camera : fakeISO100Cameras)
                if (thisCamera.equals(camera)) {
                    if (metadata.getISO() == 100) {
                        actualExposure -= 1;
                    }
                    break;
                }

            // The matrix taking into account the camera color space and its basic white balance and exposure
            float camMatrix[][] = new Matrix(cameraRGB(temperature)).times(Math.pow(2, actualExposure)).getArrayFloat();

            front = new HighlightRecoveryOpImage(front, preMul, camMatrix, CA.getArrayFloat(), null);

            if (tint != 0)
                front = WhiteBalanceV2.tintCast(front, tint, lightness);

            front.setProperty(JAIContext.PERSISTENT_CACHE_TAG, Boolean.TRUE);

            /*** NOISE REDUCTION ***/

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

            if (color_noise != 0) {
                ColorScience.LinearTransform transform = new ColorScience.YST();

                double[][] rgb2llab = transform.fromRGB(back.getSampleModel().getDataType());
                double[][] llab2rgb = transform.toRGB(back.getSampleModel().getDataType());

                ParameterBlock pb = new ParameterBlock();
                pb.addSource( front );
                pb.add( rgb2llab );
                PlanarImage ystImage = JAI.create("BandCombine", pb, null);

                pb = new ParameterBlock();
                pb.addSource(ystImage);
                pb.add(color_noise * scale);
                pb.add(0.02f + 0.001f * color_noise);
 
View Full Code Here

    ////////// main() /////////////////////////////////////////////////////////

    public static void main(String[] args) throws Exception {
        try {
            final LCTIFFReader tiff = new LCTIFFReader( args[0] );
            final PlanarImage image = tiff.getImage( null );

            final LCTIFFWriter writer = new LCTIFFWriter(
                "/Users/pjl/Desktop/out.tiff", args[1],
                image.getWidth(), image.getHeight()
            );
            writer.setStringField( TIFF_SOFTWARE, Version.getApplicationName() );
            writer.putImageStriped( image, null );
        }
        catch ( Exception e ) {
View Full Code Here

                                        boolean read2nd )
        throws BadImageFileException, UserCanceledException
    {
        try {
            final String fileName = imageInfo.getFile().getAbsolutePath();
            final PlanarImage image;

            if (true) {
                final LCTIFFReader reader =
                    new LCTIFFReader( fileName, read2nd );
                image = reader.getImage( thread );

                assert image instanceof CachedImage
                        && image.getTileWidth() == JAIContext.TILE_WIDTH
                        && image.getTileHeight() == JAIContext.TILE_HEIGHT;
            } else {
                final PlanarImage tiffImage =
                    new LCTIFFReader.TIFFImage( fileName );
                if (tiffImage.getTileWidth() != JAIContext.TILE_WIDTH ||
                    tiffImage.getTileHeight() != JAIContext.TILE_HEIGHT) {
                    final RenderingHints formatHints = new RenderingHints(
                        JAI.KEY_IMAGE_LAYOUT,
                        new ImageLayout(
                            0, 0, JAIContext.TILE_WIDTH, JAIContext.TILE_HEIGHT,
                            tiffImage.getSampleModel(),
                            tiffImage.getColorModel()
                        )
                    );
                    final ParameterBlock pb = new ParameterBlock();
                    pb.addSource(tiffImage);
                    pb.add(tiffImage.getSampleModel().getDataType());
                    image = JAI.create("Format", pb, formatHints);
                    image.setProperty(JAIContext.PERSISTENT_CACHE_TAG, Boolean.TRUE);
                } else
                    image = tiffImage;
            }
View Full Code Here

            this.op = op;
        }

        public PlanarImage setFront() {
            if (hasMask()) {
                PlanarImage labImage = Functions.toColorSpace(back, new LCMS_ColorSpace(new LCMS.LABProfile()),
                                                              LCMSColorConvertDescriptor.RELATIVE_COLORIMETRIC, null);
                // PlanarImage labImage = Functions.toColorSpace(back, JAIContext.labColorSpace, null);

                RenderedImage redMask = new RedMaskOpImage(labImage, tolerance, null);
View Full Code Here

TOP

Related Classes of com.lightcrafts.mediax.jai.PlanarImage

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.