Package jjil.algorithm

Examples of jjil.algorithm.RgbShrink


        if (this.imageInput != null && this.imInput != null) {
            int nTargetWidth = Math.min(imInput.getWidth(),g.getClipWidth());
            int nTargetHeight = Math.min(imInput.getHeight(),g.getClipHeight());
            // convert the image to gray and then
            // warp the image to the clipping size
            RgbShrink rs = new RgbShrink(nTargetWidth, nTargetHeight);
            rs.push(this.imInput);
           
            if (this.dh != null && !this.dh.isEmpty()) {
                jjil.core.Gray8Image imMask = null;
                jjil.core.Image image = dh.getFront();
                if (image instanceof jjil.core.Gray8Image) {
                   imMask = (Gray8Image) image;
                   GrayConnComp gcc = new GrayConnComp();
                   gcc.push(imMask);
                   if (gcc.getComponents()> 0) {
                       // found a face
                       Rect r = gcc.getComponent(0);
                       // calculate center of face in mask coordinates
                       int x = r.getLeft() + r.getWidth() / 2;
                       int y = r.getTop() + r.getHeight() / 2;
                       // convert from mask to original image
                       x = (x * this.imInput.getWidth()) / imMask.getWidth();
                       y = (y * this.imInput.getHeight()) / imMask.getHeight();
                       // (x,y) is the center of the detected face
                   }
                } else if (image instanceof jjil.core.Gray32Image) {
                    jjil.algorithm.Gray322Gray8 g322g8 =
                            new jjil.algorithm.Gray322Gray8();
                    g322g8.push(image);
                    imMask = (Gray8Image) g322g8.getFront();
                } else if (image instanceof jjil.core.RgbImage) {
                    RgbAvg2Gray r2g = new RgbAvg2Gray();
                    r2g.push(image);
                    imMask = (Gray8Image) r2g.getFront();
                }
                if (imMask != null) {
                    // shrink the mask to fit the display
                    GrayShrink gs = new GrayShrink(nTargetWidth, nTargetHeight);
                    gs.push(imMask);
                    imMask = (Gray8Image) gs.getFront();
                    // combine the gray image and the mask to make a displayable image
                    ApplyMaskRgb am = new ApplyMaskRgb();
                    RgbImage rgb = am.push((RgbImage)rs.getFront(), imMask);
                    g.setColor(0x0000FF00); // green
                    g.fillRect(
                            g.getClipX(),
                            g.getClipY(),
                            g.getClipWidth(),
                            g.getClipHeight());
                    g.drawImage(
                            RgbImageJ2me.toImage(rgb),
                            g.getClipX() + (g.getClipWidth() - rgb.getWidth())/2,
                            g.getClipY() + (g.getClipHeight() - rgb.getHeight())/2,
                            0);
                } else {
                    RgbImage rgb = (RgbImage) rs.getFront();
                    g.setColor(0x00FF0000); // red
                    g.fillRect(
                            g.getClipX(),
                            g.getClipY(),
                            g.getClipWidth(),
View Full Code Here


        if (this.imageInput != null && this.imInput != null) {
            int nTargetWidth = Math.min(imInput.getWidth(),g.getBitmapWidth());
            int nTargetHeight = Math.min(imInput.getHeight(),g.getBitmapHeight());
            // convert the image to gray and then
            // warp the image to the clipping size
            RgbShrink rs = new RgbShrink(nTargetWidth, nTargetHeight);
            rs.Push(this.imInput);
           
            if (this.dh != null && !this.dh.Empty()) {
                jjil.core.Gray8Image imMask = null;
                jjil.core.Image image = dh.Front();
                if (image instanceof jjil.core.Gray8Image) {
                   imMask = (Gray8Image) image;
                } else if (image instanceof jjil.core.Gray32Image) {
                    jjil.algorithm.Gray322Gray8 g322g8 =
                            new jjil.algorithm.Gray322Gray8();
                    g322g8.Push(image);
                    imMask = (Gray8Image) g322g8.Front();
                } else if (image instanceof jjil.core.RgbImage) {
                    RgbAvg2Gray r2g = new RgbAvg2Gray();
                    r2g.Push(image);
                    imMask = (Gray8Image) r2g.Front();
                }
                if (imMask != null) {
                    // shrink the mask to fit the display
                    GrayShrink gs = new GrayShrink(nTargetWidth, nTargetHeight);
                    gs.Push(imMask);
                    imMask = (Gray8Image) gs.Front();
                    // combine the gray image and the mask to make a displayable image
                    ApplyMaskRgb am = new ApplyMaskRgb();
                    RgbImage rgb = am.Push((RgbImage)rs.Front(), imMask);
                    g.drawARGB(0, 0, 255, 0); // green
                    g.drawBitmap(
                            RgbImageAndroid.toBitmap(rgb),
                            new Rect(0, 0, rgb.getWidth(), rgb.getHeight()),
                            new Rect(
                                (g.getBitmapWidth() - rgb.getWidth())/2,
                                (g.getBitmapHeight() - rgb.getHeight())/2,
                                rgb.getWidth(),
                                rgb.getHeight()),
                            new Paint());
                } else {
                    RgbImage rgb = (RgbImage) rs.Front();
                    g.drawARGB(0, 255, 0, 0); // red
                    g.drawBitmap(
                            RgbImageAndroid.toBitmap(rgb),
                            new Rect(0, 0, rgb.getWidth(), rgb.getHeight()),
                            new Rect(
View Full Code Here

TOP

Related Classes of jjil.algorithm.RgbShrink

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.