ofxCvColorImage
The ofxCvColorImage represents the data of each pixel as unsigned char values, like the ofxCvGrayscaleImage, but has 3 channels, RGB, to represent color images.
- ofxCvColorImage()
- clear()
- set(...)
- operator-=(...)
- operator+=(...)
- setFromPixels(...)
- setRoiFromPixels(...)
- setFromGrayscalePlanarImages(...)
- operator=(...)
- convertToGrayscalePlanarImages(...)
- convertToGrayscalePlanarImage(...)
- contrastStretch()
- convertToRange(...)
- resize(...)
- scaleIntoMe(...)
- convertRgbToHsv()
- convertHsvToRgb()
ofxCvColorImage methods
ofxCvColorImage(...)
ofxCvColorImage::ofxCvColorImage(const ofxCvColorImage &mom)
Copy constructor, which allows you to this:
ofxCvShortImage old;
// allocate old
ofxCvShortImage new(old);
clear()
void ofxCvColorImage::clear()
Clears the pixel data of the image. The image must be allocated again with a call to allocate() before it can be used.
set(...)
void ofxCvColorImage::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.
set(...)
void ofxCvColorImage::set(int valueR, int valueG, int valueB)
Set all the pixels in the image to the float value passed in as a color using 0 to 255 scale for each channel. This is useful for blanking or filling an image quickly.
operator-=(...)
void ofxCvColorImage::operator-=(float value)
Subtracts the pixel data of the right hand side image from the current image:
first -= second; // both are ofxCvFloatImage instances
operator+=(...)
void ofxCvColorImage::operator+=(float value)
Adds the pixel data of the right hand side image from the current image:
first += second; // both are ofxCvFloatImage instances
setFromPixels(...)
void ofxCvColorImage::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.
setRoiFromPixels(...)
void ofxCvColorImage::setRoiFromPixels(const unsigned char *_pixels, int w, int h)
Set the Region Of Interest using a pointer to an unsigned char array and a w,h to define the area of the ROI
setFromGrayscalePlanarImages(...)
void ofxCvColorImage::setFromGrayscalePlanarImages(ofxCvGrayscaleImage &red, ofxCvGrayscaleImage &green, ofxCvGrayscaleImage &blue)
This method allows you use multiple ofxCvGrayscaleImage images to create a full color image. Each ofxCvGrayscaleImage represents the data of one channel, r, g, b.
operator=(...)
void ofxCvColorImage::operator=(unsigned char *_pixels)
Sets the ofxCvColorImage from the pixels pointer. Be sure that the pixels are the same size and dimensions as the ofxCvColorImage.
operator=(...)
void ofxCvColorImage::operator=(const ofxCvGrayscaleImage &mom)
Copies ofxCvGrayscaleImage to another ofxCvShortImage using the = symbol.
~~~~{.cpp} imageOne = imageTwo; // make sure that the dimensions and ROI match
operator=(...)
void ofxCvColorImage::operator=(const ofxCvColorImage &mom)
Copies the data from an ofxCvColorImage into the instance using the = symbol.
colorImage1 = colorImage2; // make sure that the dimensions and ROI match
operator=(...)
void ofxCvColorImage::operator=(const ofxCvFloatImage &mom)
Copies the data from an ofxCvFloatImage into a ofxCvShortImage using the = symbol.
colorImage = floatColorImage; // make sure that the dimensions and ROI match
operator=(...)
void ofxCvColorImage::operator=(const ofxCvShortImage &mom)
Copies the data from a ofxCvShortImage into the ofxCvColorImage using the = symbol.
colorImage = shortColorImage; // make sure that the dimensions and ROI match
operator=(...)
void ofxCvColorImage::operator=(const IplImage *mom)
Copies the data from an IplImage into the ofxCvColorImage using the = symbol.
convertToGrayscalePlanarImages(...)
void ofxCvColorImage::convertToGrayscalePlanarImages(ofxCvGrayscaleImage &red, ofxCvGrayscaleImage &green, ofxCvGrayscaleImage &blue)
Copies the different channels of the ofxCvColorImage into 3 different grayscale images using the R G and B channels of the ofxCvColorImage.
convertToGrayscalePlanarImage(...)
void ofxCvColorImage::convertToGrayscalePlanarImage(ofxCvGrayscaleImage &grayImage, int whichPlane)
Copies the pixels of the ofxCvColorImage into an ofxCvGrayscale image. You can optionally specify whether you want to use the R G or B channel of the ofxCvColorImage to set the values of the ofxCvGrayscale.
contrastStretch()
void ofxCvColorImage::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.
convertToRange(...)
void ofxCvColorImage::convertToRange(float min, float max)
Maps the pixels of an image to the min and max range passed in.
colors.setFromPixels(grabber.getPixelsRef());
first = colors; // will leave unaltered
second = colors; // change it
second.convertToRange(100, 140); // super low contrast

scaleIntoMe(...)
void ofxCvColorImage::scaleIntoMe(ofxCvImage &mom, int interpolationMethod=CV_INTER_NN)
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
convertRgbToHsv()
void ofxCvColorImage::convertRgbToHsv()
Converts the image from values in the Red Green and Blue color space to values in the Hue Saturation and Value color space (sometimes called Hue Saturation Brightness)

convertHsvToRgb()
void ofxCvColorImage::convertHsvToRgb()
Converts the image from values in the Hue Saturation and Value color space (sometimes called Hue Saturation Brightness) to values in the Red Green and Blue color space.
