Class YarpImageHelper


  • public class YarpImageHelper
    extends java.lang.Object
    Helper class to convert YARP image to Matlab matrices (images).
    • Constructor Summary

      Constructors 
      Constructor Description
      YarpImageHelper​(int h, int w)
      Constructor, specify height and width of the image you are going to convert.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float[][] get2DMatrix​(ImageFloat img)
      Converts a floating point YARP image to a two dimensional array.
      short[][] get2DMatrix​(ImageRgb img)
      Converts a color YARP image to a two dimensional array.
      float[][] get2DMatrixBlue​(ImageRgbFloat img)
      Access a floating point YARP image by planes.
      float[][] get2DMatrixGreen​(ImageRgbFloat img)
      Access a floating point YARP image by planes.
      float[][] get2DMatrixRed​(ImageRgbFloat img)
      Access a floating point YARP image by planes.
      short[][][] get3DMatrix​(ImageRgb img)
      Converts a YARP image to a 3D array.
      short[][] getB​(ImageRgb img)
      Access a YARP image by planes.
      short[][] getG​(ImageRgb img)
      Access a YARP image by planes.
      short[][] getMonoMatrix​(ImageRgb img)
      Converts a YARP image to grayscale.
      short[][] getR​(ImageRgb img)
      Access a YARP image by planes.
      static short[] getRawImg​(ImageRgb img)
      Fast conversion of a YARP image to a one dimensional array.
      ImageRgb setRawImg​(short[] vec1ds, int height, int width, int pixelSize)
      Fast conversion from matlab image format (based on leo's structure) to a YARP image format in MATLAB, the reshape function to modify the matrix to be a 1d vector IN = reshape(label, [h*w*pixelSize 1]); and, if not previously done cast it to int16 eg: tempImg = cast(IN,'int16'); \author Vadim Tikhanoff
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • YarpImageHelper

        public YarpImageHelper​(int h,
                               int w)
        Constructor, specify height and width of the image you are going to convert.
        Parameters:
        h - image height
        w - image width
    • Method Detail

      • getMonoMatrix

        public short[][] getMonoMatrix​(ImageRgb img)
        Converts a YARP image to grayscale. Returns a height by width two dimensional array. This array is compatible with a Matlab matrix.
        Parameters:
        img - input image
        Returns:
        the two dimensional array which contains the image
      • get3DMatrix

        public short[][][] get3DMatrix​(ImageRgb img)
        Converts a YARP image to a 3D array. This array is compatible with a [HxWx3] Matlab matrix. Note: passing 3d arrays from/to Matlab/Java is SLOW (at least on Matlab 6.5); use getB/getR/getG or get2DMatrix.
        Parameters:
        img - input image
        Returns:
        the three dimensional array which contains the image
      • getR

        public short[][] getR​(ImageRgb img)
        Access a YARP image by planes. Returns a 2D array which contains the red plane, this is a [HxW] array compatible with Matlab.
        Parameters:
        img - input image
        Returns:
        the two dimensional array which contains the red plane
      • getG

        public short[][] getG​(ImageRgb img)
        Access a YARP image by planes. Returns a 2D array which contains the green plane, this is a [HxW] array compatible with Matlab.
        Parameters:
        img - input image
        Returns:
        the two dimensional array which contains the green plane
      • getB

        public short[][] getB​(ImageRgb img)
        Access a YARP image by planes. Returns a 2D array which contains the blue plane, this is a [HxW] array compatible with Matlab.
        Parameters:
        img - input image
        Returns:
        the two dimensional array which contains the blue plane
      • get2DMatrix

        public short[][] get2DMatrix​(ImageRgb img)
        Converts a color YARP image to a two dimensional array. Returns a [Hx3*W] array which contains the 'justaposition' of the three color planes of the image. This array can be copied into a Matlab matrix: OUT=[R|G|B] where R, G, B are three [HxW] matrices formed by the color planes. From OUT you can create a color image [HxWx3] by typing: IMG=uint8(H,W,3); IMG(:,:,1)=OUT(:,1:W); IMG(:,:,2)=OUT(:,W+1:2*W); IMG(:,:,3)=OUT(:,2*W+1:3*W);
        Parameters:
        img - input image
        Returns:
        output array
      • get2DMatrix

        public float[][] get2DMatrix​(ImageFloat img)
        Converts a floating point YARP image to a two dimensional array.
        Parameters:
        img - input image
        Returns:
        output array
      • get2DMatrixRed

        public float[][] get2DMatrixRed​(ImageRgbFloat img)
        Access a floating point YARP image by planes. Returns a 2D array which contains the red plane, this is a [HxW] array compatible with Matlab.
        Parameters:
        img - input image
        Returns:
        the two dimensional array which contains the red plane
      • get2DMatrixGreen

        public float[][] get2DMatrixGreen​(ImageRgbFloat img)
        Access a floating point YARP image by planes. Returns a 2D array which contains the green plane, this is a [HxW] array compatible with Matlab.
        Parameters:
        img - input image
        Returns:
        the two dimensional array which contains the green plane
      • get2DMatrixBlue

        public float[][] get2DMatrixBlue​(ImageRgbFloat img)
        Access a floating point YARP image by planes. Returns a 2D array which contains the blue plane, this is a [HxW] array compatible with Matlab.
        Parameters:
        img - input image
        Returns:
        the two dimensional array which contains the blue plane
      • getRawImg

        public static short[] getRawImg​(ImageRgb img)
        Fast conversion of a YARP image to a one dimensional array. In MATLAB, USE: reshape(OUT, [height width pixelsize]); Extended function to work with padding (Vadim Tikhanoff) \author Leo Pape
        Parameters:
        img - input image
        Returns:
        output array
      • setRawImg

        public ImageRgb setRawImg​(short[] vec1ds,
                                  int height,
                                  int width,
                                  int pixelSize)
        Fast conversion from matlab image format (based on leo's structure) to a YARP image format in MATLAB, the reshape function to modify the matrix to be a 1d vector IN = reshape(label, [h*w*pixelSize 1]); and, if not previously done cast it to int16 eg: tempImg = cast(IN,'int16'); \author Vadim Tikhanoff
        Returns:
        output yarp image