I just finished the WBC segmentation. For segmentation, i used the RGB histogram.
RGB Histogram
- Calculate the R, G and B histograms
- for(int i = 0; i < histogram_size; i++)
rgbHistogram[i] = rHistogram[i] + gHistogram[i] + bHistogram[i];
Hope you get an idea.
After that, I find out a threshold value from the histogram, and did a linear contrast stretching to segment the background.
While doing so, I implemented a wrapper class for IplImage, where we can access pixel values in the form image[i][j] and many histogram related functions for the preprocessor.
I started developing the header files. Will finish it soon.
Sunday, April 15, 2007
Subscribe to:
Post Comments (Atom)
2 comments:
The wrapper class for iplImage sounds good. But I came across this *possible* problem for having 2-D array like thing for image data. Anyway, I could be wrong, but thought of mentioning it here.
"Note: If you have a large 2d array (*cough* image *cough*) it's often faster to represent it as a 1d array instead because of better cache coherency. Every time you call new you're getting a block of memory from who knows where. In other words, you aren't guaranteed contiguous areas of memory."
From -
http://www.cs.brown.edu/courses/cs123/javatoc.shtml#MultiArray
Omega,
This is again regarding the wrapper class :)
I found this in the OpenCV documentation. Please check with this also.
********************************
*Direct access using a c++ wrapper: (Simple and efficient access)
* Define a c++ wrapper for single-channel byte images, multi-channel byte images, and multi-channel float images:
template < class T > class Image
{
private:
IplImage* imgp;
public:
Image(IplImage* img=0) {imgp=img;}
~Image(){imgp=0;}
void operator=(IplImage* img) {imgp=img;}
inline T* operator[](const int rowIndx) {
return ((T *)(imgp->imageData + rowIndx*imgp->widthStep));}
};
typedef struct{
unsigned char b,g,r;
} RgbPixel;
typedef struct{
float b,g,r;
} RgbPixelFloat;
typedef Image < RgbPixel > RgbImage;
typedef Image < RgbPixelFloat > RgbImageFloat;
typedef Image < unsigned char > BwImage;
typedef Image < float > BwImageFloat;
* For a single-channel byte image:
IplImage* img=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1);
BwImage imgA(img);
imgA[i][j] = 111;
* For a multi-channel byte image:
IplImage* img=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3);
RgbImage imgA(img);
imgA[i][j].b = 111;
imgA[i][j].g = 111;
imgA[i][j].r = 111;
* For a multi-channel float image:
IplImage* img=cvCreateImage(cvSize(640,480),IPL_DEPTH_32F,3);
RgbImageFloat imgA(img);
imgA[i][j].b = 111;
imgA[i][j].g = 111;
imgA[i][j].r = 111;
*********************************
Post a Comment