当前位置: 首页>>代码示例>>Java>>正文


Java MBFImage.getWidth方法代码示例

本文整理汇总了Java中org.openimaj.image.MBFImage.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java MBFImage.getWidth方法的具体用法?Java MBFImage.getWidth怎么用?Java MBFImage.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openimaj.image.MBFImage的用法示例。


在下文中一共展示了MBFImage.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doTutorial

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void doTutorial(MBFImage toDraw) {
    final MBFImage space = ColourSpace.convert(toDraw, ColourSpace.CIE_Lab);

    if (cluster == null)
        cluster = clusterPixels(space);

    if (cluster == null)
        return;

    final float[][] centroids = cluster.getCentroids();

    final ExactFloatAssigner assigner = new ExactFloatAssigner(cluster);

    for (int y = 0; y < space.getHeight(); y++) {
        for (int x = 0; x < space.getWidth(); x++) {
            final float[] pixel = space.getPixelNative(x, y);
            final int centroid = assigner.assign(pixel);
            space.setPixelNative(x, y, centroids[centroid]);
        }
    }

    toDraw.internalAssign(ColourSpace.convert(space, ColourSpace.RGB));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:SegmentationTutorial.java

示例2: beforeUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
    if (this.comp.getWidth() <= 10) {
        Insets insets = this.getInsets();
        int width = this.getWidth() - insets.left - insets.right;
        int height = (int) (((float)width / (float)frame.getWidth())*frame.getHeight());
                    
        this.comp.setSize(width, height);
        this.comp.setPreferredSize(new Dimension(width,height));
        this.validate();
    }
    
    toDraw.internalCopy(frame);
    doTutorial(toDraw);
    this.comp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay( toDraw, bimg ));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:TutorialPanel.java

示例3: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    final MBFImage image = ImageUtilities.readMBF(new File("/Users/jsh2/Pictures/08-earth_shuttle2.jpg"));

    int[] pixels = image.toPackedARGBPixels();

    Arrays.sort(pixels);
    final MBFImage sorted = new MBFImage(pixels, image.getWidth(), image.getHeight());
    ImageUtilities.write(sorted, new File("/Users/jsh2/Pictures/sorted.jpg"));

    final List<Integer> plist = Arrays.asList(ArrayUtils.toObject(pixels));
    Collections.shuffle(plist);
    pixels = ArrayUtils.toPrimitive(plist.toArray(new Integer[pixels.length]));
    final MBFImage shuffled = new MBFImage(pixels, image.getWidth(), image.getHeight());
    ImageUtilities.write(shuffled, new File("/Users/jsh2/Pictures/shuffled.jpg"));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:PixelShuffle.java

示例4: drawBoxes

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * 	Draws the boxes to show movements.
 *	@param img The image to draw to
 */
protected void drawBoxes( final MBFImage img, final double[][] sim )
{
    final int gw = img.getWidth()  / this.nGridElements;
    final int gh = img.getHeight() / this.nGridElements;
    for( int y = 0; y < this.nGridElements; y++ )
    {
        for( int x = 0; x < this.nGridElements; x++ )
        {
            Float[] c = new Float[]{0f,0f,0f,0f};
            if( sim[y][x] == this.boostFactor )
                    c = RGBColour.RED;
            else
            if( sim[y][x] == this.limitingFactor )
                    c = RGBColour.BLUE;
            else	c = RGBColour.BLACK;
            img.drawShape( new Rectangle(x*gw,y*gh,gw,gh), c );
        }
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:LocalHistogramVideoShotDetector.java

示例5: imageToVector

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
protected float[][] imageToVector(MBFImage image) {
    final int height = image.getHeight();
    final int width = image.getWidth();
    final int bands = image.numBands();

    final float[][] f = new float[height * width][bands + 2];
    for (int b = 0; b < bands; b++) {
        final float[][] band = image.getBand(b).pixels;
        final float w = scaling == null ? 1 : scaling[b];

        for (int y = 0; y < height; y++)
            for (int x = 0; x < width; x++)
                f[x + y * width][b] = band[y][x] * w;
    }
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            f[x + y * width][bands] = ((float) x / (float) width) * (scaling == null ? 1 : scaling[bands]);
            f[x + y * width][bands + 1] = ((float) y / (float) height) * (scaling == null ? 1 : scaling[bands + 1]);
        }
    }

    return f;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:KMSpatialColourSegmenter.java

示例6: VisualisationImpl

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * 	Create a new visualisation using an existing image.
 *	@param overlayOn The visualisation on which to overlay
 */
public VisualisationImpl( final VisualisationImpl<?> overlayOn )
{
    this.overlaidOn = overlayOn;

    // Create an image the same size as the overlay vis
    final MBFImage vi = overlayOn.getVisualisationImage();
    this.visImage = new MBFImage( vi.getWidth(), vi.getHeight(), 4 );
    this.dbImage = this.visImage.clone();
    this.setPreferredSize( new Dimension( vi.getWidth(), vi.getHeight() ) );
    this.setSize( new Dimension( vi.getWidth(), vi.getHeight() ) );
    this.requiredSize = this.getSize();

    // Add this as an overlay on the other vis. This also forces
    // an update so that we get their visualisation to overlay on
    overlayOn.addOverlay( this );
    this.addComponentListener( this );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:VisualisationImpl.java

示例7: calculateIntensity

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Calculate intensity by averaging R, G, B planes. Assumes planes are all
 * in the same magnitude.
 * 
 * @param in
 *            MBFImage with 3 bands
 * @return intensity image
 */
public static FImage calculateIntensity(final MBFImage in) {
    if (in.colourSpace != ColourSpace.RGB && in.colourSpace != ColourSpace.RGBA)
        throw new UnsupportedOperationException("Can only convert RGB or RGBA images");

    final FImage out = new FImage(in.getWidth(), in.getHeight());

    for (int r = 0; r < in.getHeight(); r++) {
        for (int c = 0; c < in.getWidth(); c++) {
            out.pixels[r][c] = (in.getBand(0).pixels[r][c] +
                    in.getBand(1).pixels[r][c] +
                    in.getBand(2).pixels[r][c]) / 3.0F;
        }
    }

    return out;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:Transforms.java

示例8: addMustaches

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Detect faces in the image and render mustaches.
 * 
 * @param image
 * @return image with rendered mustaches
 */
public MBFImage addMustaches(MBFImage image) {
    MBFImage cimg;

    if (image.getWidth() > image.getHeight() && image.getWidth() > 640) {
        cimg = image.process(new ResizeProcessor(640, 480));
    } else if (image.getHeight() > image.getWidth() && image.getHeight() > 640) {
        cimg = image.process(new ResizeProcessor(480, 640));
    } else {
        cimg = image.clone();
    }

    final FImage img = Transforms.calculateIntensityNTSC(cimg);

    final List<KEDetectedFace> faces = detector.detectFaces(img);
    final MBFImageRenderer renderer = cimg.createRenderer();

    for (final KEDetectedFace face : faces) {
        final Matrix tf = AffineAligner.estimateAffineTransform(face);
        final Shape bounds = face.getBounds();

        final MBFImage m = mustache.transform(tf.times(TransformUtilities.scaleMatrix(1f / 4f, 1f / 4f)));

        renderer.drawImage(m, (int) bounds.minX(), (int) bounds.minY());
    }

    return cimg;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:Mustache.java

示例9: analyseImage

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void analyseImage(MBFImage image) {
    final int width = image.getWidth();
    final int height = image.getHeight();

    image = ColourSpace.convert(image, ColourSpace.RGB);

    final FImage r = image.getBand(0);
    final FImage g = image.getBand(1);
    final FImage b = image.getBand(2);

    double avgr = 0;
    double avgg = 0;
    double avgb = 0;
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            avgr += r.pixels[y][x];
            avgg += g.pixels[y][x];
            avgb += b.pixels[y][x];
        }
    }
    avgr /= (width * height);
    avgg /= (width * height);
    avgb /= (width * height);

    contrast = 0;
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            final double deltar = r.pixels[y][x] - avgr;
            final double deltag = g.pixels[y][x] - avgg;
            final double deltab = b.pixels[y][x] - avgb;

            contrast += (deltar * deltar) + (deltag * deltag) + (deltab * deltab);
        }
    }

    contrast /= (height * width);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:39,代码来源:RGBRMSContrast.java

示例10: analyseImage

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void analyseImage(MBFImage image) {
    image.analyseWith(saliencyGenerator);
    final TObjectFloatHashMap<ConnectedComponent> componentMap = saliencyGenerator.getSaliencyComponents();

    final float max = ArrayUtils.maxValue(componentMap.values());

    final FImage map = new FImage(image.getWidth(), image.getHeight());
    final float thresh = max * alpha;
    final BoundingBoxRenderer<Float> renderer = new BoundingBoxRenderer<Float>(map, 1F, true);

    componentMap.forEachEntry(new TObjectFloatProcedure<ConnectedComponent>() {
        @Override
        public boolean execute(ConnectedComponent cc, float sal) {
            if (sal >= thresh) { // note that this is reversed from the
                // paper, which doesn't seem to make
                // sense.
                renderer.process(cc);
            }

            return true;
        }
    });

    roiProportion = 0;
    for (int y = 0; y < map.height; y++)
        for (int x = 0; x < map.width; x++)
            roiProportion += map.pixels[y][x];

    roiProportion /= (map.width * map.height); // smaller simplicity means
    // smaller ROI
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:33,代码来源:ROIProportion.java

示例11: drawToImage

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void drawToImage(MBFImage image) {
    image.fill(RGBColour.WHITE);
    final int nPoints = touchArray.size();
    final float gridX = nPoints % (GRIDX + 1);
    final float gridY = nPoints / (GRIDX + 1);

    final Point2dImpl currentpoint = new Point2dImpl(
            (image.getWidth() * (gridX / GRIDX)),
            ((image.getHeight()) * (gridY / GRIDY))
            );
    drawTarget(image, currentpoint);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:14,代码来源:TouchTableScreen.java

示例12: drawSpLine

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private static void drawSpLine(SimplePerceptron mkp) {
    final MBFImage img = new MBFImage(300, 300, ColourSpace.RGB);
    final double[] startD = new double[] { 0, Double.NaN };
    final double[] endD = new double[] { img.getWidth(), Double.NaN };

    drawLine(img, mkp.computeHyperplanePoint(startD), mkp.computeHyperplanePoint(endD));
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:8,代码来源:DrawLinearData.java

示例13: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * 	Main method.
 *	@param args command-line args (unused)
 */
public static void main( final String[] args )
{
    // Create an image to fill
    final MBFImage swatchS1 = new MBFImage( 800, 800, 3 );

    // Loop over the image
    for( int y = 0; y < swatchS1.getHeight(); y++ ) {
        for( int x = 0; x < swatchS1.getWidth(); x++ ) {
            // Set the HSL coordinates
            final float[] hsl = new float[3];
            hsl[0] = x / (float)swatchS1.getWidth();
            hsl[1] = 1f;
            hsl[2] = 1 - (y / (float)swatchS1.getHeight());

            // Convert to RGB
            final float[] rgb = new float[3];
            Transforms.HSL_TO_RGB( hsl, rgb );

            // Set the pixel in the RGB image
            swatchS1.setPixel( x, y, new Float[]{ rgb[0], rgb[1], rgb[2] } );
        }
    }

    // Display the image
    DisplayUtilities.display( swatchS1 );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:31,代码来源:HSLSwatches.java

示例14: accum

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
protected void accum(MBFImage im) {
    if (im.numBands() != ndims)
        throw new AssertionError("number of bands must match");
    
    for (int y=0; y<im.getHeight(); y++) {
        for (int x=0; x<im.getWidth(); x++) {
            if (mask.pixels[y][x] != 1)
                continue;
            
            int [] bins = new int[ndims];
            
            for (int i=0; i<ndims; i++) {
                bins[i] = (int)(im.getBand(i).pixels[y][x] * (histogram.nbins[i]));
                if (bins[i] >= histogram.nbins[i]) bins[i] = histogram.nbins[i] - 1;
            }
            
            int bin = 0;
            for (int i=0; i<ndims; i++) {
                int f = 1;
                for (int j=0; j<i; j++)
                    f *= histogram.nbins[j];
                
                bin += f * bins[i];
            }
            
            histogram.values[bin]++;
        }
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:31,代码来源:MaskingHistogramModel.java

示例15: RGB_TO_HSL

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Transform 3 band RGB image to HSL
 * 
 * @param in
 *            RGB or RGBA image
 * @return HSL image
 */
public static MBFImage RGB_TO_HSL(final MBFImage in) {
    if (in.colourSpace != ColourSpace.RGB && in.colourSpace != ColourSpace.RGBA)
        throw new IllegalArgumentException("RGB or RGBA colourspace is required");

    final MBFImage out = in.clone();
    final float[] pix = new float[in.numBands()];
    for (int y = 0; y < in.getHeight(); y++) {
        for (int x = 0; x < in.getWidth(); x++) {
            for (int b = 0; b < in.numBands(); b++)
                pix[b] = in.getBand(b).pixels[y][x];
            Transforms.RGB_TO_HSL(pix, pix);
            for (int b = 0; b < in.numBands(); b++)
                out.getBand(b).pixels[y][x] = pix[b];
        }
    }

    // final MBFImage out = Transforms.RGB_TO_HSV(in);
    //
    // final FImage R = in.getBand(0);
    // final FImage G = in.getBand(1);
    // final FImage B = in.getBand(2);
    //
    // final FImage L = out.getBand(2);
    // for (int y = 0; y < L.height; y++) {
    // for (int x = 0; x < L.width; x++) {
    // final float max = Math.max(Math.max(R.pixels[y][x], G.pixels[y][x]),
    // B.pixels[y][x]);
    // final float min = Math.min(Math.min(R.pixels[y][x], G.pixels[y][x]),
    // B.pixels[y][x]);
    // L.pixels[y][x] = 0.5f * (max - min);
    // }
    // }

    out.colourSpace = ColourSpace.HSL;

    return out;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:45,代码来源:Transforms.java


注:本文中的org.openimaj.image.MBFImage.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。