ofDocsdocumentation addons ofxOpenCv ofxCvShortImage

ofxCvShortImage

The ofxCvShortImage represents the color data of each pixel as unsigned char variables or values between 0 and 255. They are a slightly smaller (i.e. less data heavy) way of representing the data in an image but they also have less precision than ofxCvFloatImage. Usually when you're capturing from a camera or video into OpenCV, you're using ofxCvShortImage. Keep in mind though that most of the image operations in OpenCV expect a grayscale image, which you can construct using the ofxCvGrayscaleImage.


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()

Clears the pixel data of the image. The image must be allocated again with a call to allocate() before it can be used.


contrastStretch( )

void contrastStretch()

This increases the contrast of the image remapping the brightest points in the image to white and the darkest points in the image to black.


convertGrayToShort( ... )

void convertGrayToShort(int *grayImg, int *floatImg)

convertShortToGray( ... )

void convertShortToGray(int *floatImg, int *grayImg)

convertToRange( ... )

void convertToRange(float min, float max)

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


colors.setFromPixels(grabber.getPixels());

first = colors; // will leave unaltered
second = colors; // change it
second.convertToRange(100, 140); // super low contrast

Image convert to range


flagImageChanged( )

void flagImageChanged()

Marks the image as changed so that the ofTexture can be updated, if the image contains one.


getCv8BitsImage( )

int * getCv8BitsImage()

getCv8BitsRoiImage( )

int * getCv8BitsRoiImage()

getRoiShortPixelsRef( )

ofShortPixels & getRoiShortPixelsRef()

Returns the pixel data of the instance as a ofShortPixels reference. This allows you to directly manipulate the pixels of the ofxCvShortImage.


getShortPixelsRef( )

ofShortPixels & getShortPixelsRef()

Returns the pixel data of the instance as a ofShortPixels instance.


init( )

void init()

ofxCvShortImage( )

ofxCvShortImage()

Constructor.


ofxCvShortImage( ... )

ofxCvShortImage(const ofxCvShortImage &mom)

Copy constructor, which allows you to this:

ofxCvShortImage old;
// allocate old
ofxCvShortImage new(old);

operator=( ... )

void operator=(unsigned char *_pixels)

Sets the ofxCvShortImage from the pixels pointer. Be sure that the pixels are the same size and dimensions as the ofxCvShortImage.


operator=( ... )

void operator=(const ofxCvGrayscaleImage &mom)

Copies ofxCvGrayscaleImage to the ofxCvShortImage using the = symbol.

imageOne = imageTwo; // make sure that the dimensions and ROI match

operator=( ... )

void operator=(const ofxCvColorImage &mom)

Copies a ofxCvColorImage into a ofxCvShortImage using the = symbol.

grayImage = colorImage; // make sure that the dimensions and ROI match

operator=( ... )

void operator=(const ofxCvFloatImage &mom)

opies a ofxCvFloatImage into a ofxCvShortImage using the = symbol.

grayImage = floatColorImage; // make sure that the dimensions and ROI match

operator=( ... )

void operator=(const ofxCvShortImage &mom)

Copies a ofxCvShortImage into a ofxCvShortImage using the = symbol.

grayImage = shortColorImage; // make sure that the dimensions and ROI match

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. Possible values are 0 to 255.


setFromPixels( ... )

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

Set all the pixels in a ofxCvShortImage 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.


setRoiFromPixels( ... )

void setRoiFromPixels(const unsigned char *_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.