ofDocsdocumentation addons ofxOpenCv ofxCvFloatImage

ofxCvFloatImage

ofxCvFloatImage is an image class that represents the values of each color of each pixel as float values, on a scale of 0.0 - 1.0. They are a more precise but heavier (i.e. requiring more memory) way representing the data in an image. Keep in mind though that most of the image operations in OpenCV expect a grayscale image, which you can construct using the ofxCvGrayscaleImage. If you're loading image data from another image you might want to check what image scale is being used with the image to ensure that you don't get your scales wrong.


addWeighted( ... )

void addWeighted(ofxCvGrayscaleImage &mom, float f)

Copies the pixel data of an ofxCvGrayscaleImage into the pixel data of the ofxCvShortImage.


allocatePixels( ... )

void allocatePixels(int w, int h)

allocateTexture( )

void allocateTexture()

clear( )

void clear()

Remove all pixel data from the ofxCvFloatImage instance.


contrastStretch( )

void contrastStretch()

This increases the contrast of the image remapping the brightest points in the image to 255 and the darkest points in the image to 0.


convertFloatToGray( ... )

void convertFloatToGray(int *floatImg, int *grayImg)

convertGrayToFloat( ... )

void convertGrayToFloat(int *grayImg, int *floatImg)

convertToRange( ... )

void convertToRange(float min, float max)

Maps the pixels of an image to the min and max range passed in.


second.convertToRange(100, 140); // super low contrast

Image convert to range


flagImageChanged( )

void flagImageChanged()

Flag whether the image pixel data has changed so that the ofTexture can be updated.


getCv8BitsImage( )

int * getCv8BitsImage()

getCv8BitsRoiImage( )

int * getCv8BitsRoiImage()

getFloatPixelsRef( )

ofFloatPixels & getFloatPixelsRef()

Returns a ofFloatPixels that contains the pixels of the image.


getNativeScaleMax( )

float getNativeScaleMax()

If you've set the native scale max and min using setNativeScale() this returns the maximum value.


getNativeScaleMin( )

float getNativeScaleMin()

If you've set the native scale max and min using setNativeScale() this returns the minimum value.


getPixelsAsFloats( )

float * getPixelsAsFloats()

Returns a pointer to an array of floating point numbers that represent the pixels of the image.


getRoiFloatPixelsRef( )

ofFloatPixels & getRoiFloatPixelsRef()

Returns a ofFloatPixels that contains the pixels within the ROI the image.


getRoiPixelsAsFloats( )

float * getRoiPixelsAsFloats()

Returns a pointer to an array of floating point numbers that represent the pixels of the ROI of the image.


init( )

void init()

ofxCvFloatImage( )

ofxCvFloatImage()

Constructor.


ofxCvFloatImage( ... )

ofxCvFloatImage(const ofxCvFloatImage &mom)

Copy constructor.


operator&=( ... )

void operator&=(ofxCvImage &mom)

Binary & (Logical AND http://en.wikipedia.org/wiki/Bitwise_operation) the pixel data of the right hand side image from the current image:

cvPuppy.allocate( 320, 240 );    
cvPuppy = puppyImg.getPixels(); // copy pixels from a loaded image
    
andPuppy.allocate( 320, 240 );
    
andPuppy.set(255, 0, 0); // make the AND image red
andPuppy &= cvPuppy; // will & all the bits 

puppy AND


operator*=( ... )

void operator*=(float scalar)

Multiplies the pixel data of the right hand side image from the current image:

first *= second; // both are ofxCvFloatImage instances

operator*=( ... )

void operator*=(ofxCvImage &mom)

Multiplies the pixel data of the right hand side image from the current image:

first *= second; // both are ofxCvFloatImage instances

operator/=( ... )

void operator/=(float scalar)

Divides each pixel of the pixel data of the right hand side image from the current image:

first /= second; // both are ofxCvFloatImage instances

operator=( ... )

void operator=(unsigned char *_pixels)

Copy the data from an array of unsigned char numbers into the ofxCvFloatImage instance. The dimensions of the array are assumed to match the dimensions of the image. The values will be converted to a 0.0 - 1.0 scale.


operator=( ... )

void operator=(float *_pixels)

Copy the data from an array of floating point numbers into the ofxCvFloatImage instance. The dimensions of the array are assumed to match the dimensions of the image.


operator=( ... )

void operator=(const ofxCvGrayscaleImage &mom)

Copy the data from an ofxCvGrayscaleImage image into the ofxCvFloatImage instance.


operator=( ... )

void operator=(const ofxCvColorImage &mom)

Copy the data from an ofxCvColor image into the ofxCvFloatImage instance.


operator=( ... )

void operator=(const ofxCvFloatImage &mom)

Copy the data from an ofxCvFloatImage image into the ofxCvFloatImage instance.


operator=( ... )

void operator=(const ofxCvShortImage &mom)

operator=( ... )

void operator=(const int *mom)

resize( ... )

void resize(int w, int h)

Resizes the image to the w.h passed in.


scaleIntoMe( ... )

void scaleIntoMe(ofxCvImage &mom, int interpolationMethod)

Scales the image passed in to be the size of the current image,


ofxCvImage first;
first.allocate(640, 480);
ofxCvImage second;
second.allocate(320, 240);

second.scaleIntoMe(first); // first is now 320,240


set( ... )

void set(float value)

Set all the pixels in the image to the float value passed in. This is useful for blanking or filling an image quickly. the values are 0.0 to 1.0.


setFromPixels( ... )

void setFromPixels(const unsigned char *_pixels, int w, int h)

Set all the pixels in a ofxCvGrayscaleImage from a pointer to an array of unsigned char values, using the w and h parameters to determine the dimensions of the image. The array is assumed to contain color values.


setFromPixels( ... )

void setFromPixels(float *_pixels, int w, int h)

This allows you to set the ROI on the image from an array of pixels. Region of Interest is a rectangular area in an image, to segment object for further processing. Once the ROI is defined, OpenCV functions will operate on the ROI, reducing the number of pixels that the operation will examine.


setNativeScale( ... )

void setNativeScale(float _scaleMin, float _scaleMax)

Allows you to set the native scale of your images, for instance, if your images contain values ranging from 0.0 to 255.0 (unlikely, but possible) then you would want to set them to ensure that all image operations complete correctly.


setRoiFromPixels( ... )

void setRoiFromPixels(const unsigned char *_pixels, int w, int h)

This allows you to set the ROI on the image from an array of pixels. Region of Interest is a rectangular area in an image, to segment object for further processing. Once the ROI is defined, OpenCV functions will operate on the ROI, reducing the number of pixels that the operation will examine.


setRoiFromPixels( ... )

void setRoiFromPixels(float *_pixels, int w, int h)

This allows you to set the ROI on the image from an ofPixels instance. Region of Interest is a rectangular area in an image, to segment object for further processing. Once the ROI is defined, OpenCV functions will operate on the ROI, reducing the number of pixels that the operation will examine.