Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.KernelJAI


                                         StringBuffer msg) {
        if (!super.validateParameters(args, msg)) {
            return false;
        }

        KernelJAI h_kernel = (KernelJAI)args.getObjectParameter(0);
        KernelJAI v_kernel = (KernelJAI)args.getObjectParameter(1);

        /* Check if both kernels are equivalent in terms of dimensions. */
        if ((h_kernel.getWidth() != v_kernel.getWidth()) ||
            (h_kernel.getHeight() != v_kernel.getHeight())) {
            msg.append(getName() + " " +
                       JaiI18N.getString("GradientMagnitudeDescriptor1"));
                       return false;
        }
       
View Full Code Here


        RenderedImage source = args.getRenderedSource(0);

  // map the input kernel + gain factor to an equivalent
  // convolution kernel and then do a normal convolve.
  KernelJAI unRotatedKernel =
    ImageUtil.getUnsharpMaskEquivalentKernel(
      (KernelJAI)args.getObjectParameter(0),
      args.getFloatParameter(1));

        KernelJAI kJAI = unRotatedKernel.getRotatedKernel();

        int kWidth = kJAI.getWidth();
        int kHeight = kJAI.getHeight();

        /* mediaLib does not handle kernels with either dimension < 2. */
        if (kWidth < 2 || kHeight < 2) {
            return null;
        }

        if (kJAI.isSeparable() && kWidth >= 3 && kWidth <= 7 &&  kWidth == kHeight) {
            return new MlibSeparableConvolveOpImage(source,
                                                    extender, hints, layout,
                                                    kJAI);
        } else if ((kWidth == 3 && kHeight == 3) ||
                   (kWidth == 5 && kHeight == 5)) {
View Full Code Here

            dataV = new float[height];
            Arrays.fill(dataV, 1.0F/(float)height);
        }

        // Construct a separable kernel.
        KernelJAI kernel = new KernelJAI(width, height, xOrigin, yOrigin,
                                         dataH, dataV);

        // Construct the parameters for the "Convolve" RIF.
        ParameterBlock args = new ParameterBlock(paramBlock.getSources());
        args.add(kernel);
View Full Code Here

        /*
         * Get the Horizontal & Vertical kernels.
         * At this point these kernels should have the same width & height
         */
        KernelJAI kern_h = (KernelJAI)args.getObjectParameter(0);
        KernelJAI kern_v = (KernelJAI)args.getObjectParameter(1);

        /* Get the width & height of the kernels. */
        int kWidth = kern_h.getWidth();
        int kHeight = kern_v.getHeight();

        /* Check and see if the operation is a Sobel. */
        float khdata[], kvdata[];
        khdata = kern_h.getKernelData();
        kvdata = kern_v.getKernelData();
        if ((khdata[0] == -1.0F && khdata[1] == -2.0F && khdata[2] == -1.0F &&
             khdata[3] ==  0.0F && khdata[4] ==  0.0F && khdata[5] ==  0.0F &&
             khdata[6] ==  1.0F && khdata[7] ==  2.0F && khdata[8] ==  1.0F) &&
            (kvdata[0] == -1.0F && kvdata[1] == 0.0F && kvdata[2] == 1.0F &&
             kvdata[3] == -2.0F && kvdata[4] == 0.0F && kvdata[5] == 2.0F &&
View Full Code Here


        // Get BorderExtender from renderHints if any.
        BorderExtender extender = RIFUtil.getBorderExtenderHint(renderHints);

        KernelJAI unRotatedKernel =
            (KernelJAI)paramBlock.getObjectParameter(0);
        KernelJAI kJAI = unRotatedKernel.getRotatedKernel();

  RenderedImage source = paramBlock.getRenderedSource(0);

        return new LCErodeOpImage(source,
                                  extender,
View Full Code Here


        // Get BorderExtender from renderHints if any.
        BorderExtender extender = RIFUtil.getBorderExtenderHint(renderHints);

        KernelJAI unRotatedKernel =
            (KernelJAI)paramBlock.getObjectParameter(0);
        KernelJAI kJAI = unRotatedKernel.getRotatedKernel();

        int dataType =
           paramBlock.getRenderedSource(0).getSampleModel().getDataType();
        boolean dataTypeOk = (dataType == DataBuffer.TYPE_BYTE ||
                              dataType == DataBuffer.TYPE_SHORT ||
                              dataType == DataBuffer.TYPE_INT);

        if (kJAI.isSeparable()) {
           return new LCSeparableConvolveOpImage(paramBlock.getRenderedSource(0),
                                               extender,
                                               renderHints,
                                               layout,
                                               kJAI);
View Full Code Here

      newData[k] = -gain * oldData[k];

  k = yOrigin*width + xOrigin;
  newData[k] = 1.0f + gain * (1.0f - oldData[k]);

  return new KernelJAI(width, height, xOrigin, yOrigin, newData);
    }
View Full Code Here

                RenderedImage redMask = new RedMaskOpImage(labImage, tolerance, null);

                ParameterBlock pb;

                KernelJAI morphKernel = new KernelJAI(3, 3, new float[] {1, 1, 1, 1, 0, 1, 1, 1, 1});
                pb = new ParameterBlock();
                pb.addSource(redMask);
                pb.add(morphKernel);
                redMask = JAI.create("dilate", pb, null);

                /* pb = new ParameterBlock();
                pb.addSource(redMask);
                pb.add(morphKernel);
                redMask = JAI.create("erode", pb, null); */

                KernelJAI blurKernel = Functions.getGaussKernel(4 * scale);
                pb = new ParameterBlock();
                pb.addSource(redMask);
                pb.add(blurKernel);
                redMask = JAI.create("LCSeparableConvolve", pb, null);

View Full Code Here

        return dst;
    }

    static private BufferedImage getGaussianBlur(int size, BufferedImage image) {
        KernelJAI kernel = Functions.getGaussKernel(size / 3.0);
        ParameterBlock pb = new ParameterBlock();
        pb.addSource(image);
        pb.add(kernel);
        RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                  BorderExtender.createInstance(BorderExtender.BORDER_COPY));
View Full Code Here

        g2d.dispose();
        return mask;
    }

    private BufferedImage getGaussianBlur(int size, BufferedImage image) {
        KernelJAI kernel = Functions.getGaussKernel(size / 3.0);
        ParameterBlock pb = new ParameterBlock();
        pb.addSource(image);
        pb.add(kernel);
        RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                  BorderExtender.createInstance(BorderExtender.BORDER_COPY));
View Full Code Here

TOP

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

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.