Reputation: 66935
We have some 2d data parser that recives images of size 8x8 (roiSize=8) which are sent to our parser from something like:
void UseOurParser(IplImage* destination)
{
int w = destination->width;
int h = destination->height;
original = cvCreateImage(cvSize(w, h),IPL_DEPTH_8U,1);
cvCvtColor(destination,original,CV_RGB2GRAY);
cout << endl << "Progress:";
for(int j = 1; j < original->width/roiSize-1; j=j++) {
cout << "." ;
for(int i = 1; i < original->height/roiSize-1; i=i++) {
cvSetImageROI(original, cvRect(j*roiSize, i*roiSize,roiSize, roiSize));
IplImage *cropSource = cvCreateImage(cvGetSize(original), original->depth, original->nChannels);
cvCopy(original, cropSource, NULL);
ProcessOurParser(cropSource, j, i);
cvResetImageROI(original);
}
} //...
Our parser takes an image j, i and inside it can determine if an object was found on an image. And if it was found it performs another operation that determins some feature value (some float). I want somehow to create a 2d representation of my data (of size like (original->width/roiSize-2) X (original->height/roiSize-2)) so to each roi I'd have a value declaring if feature was found in it or not and if it was its feature value. What I need is to be capable to iterate through generated data. and implement some kind of region grouse algorithm so that if feature on one roi is == to feature on another that is one of 8 surrounding it we somehow grow region and check again and again so we find regions...
So if we were searching for lines and our features were bool for line existence and angle float (as I do) we would do something like
1) (we stand on blue 1 and 2 yellow 1s are points of our interest)
We submited to our "line" that 2 regions and continue searching
We found hat feature on one roi is related to our line and another is not so we will return to that roi later
so is there any help in boost on how to do such thing or any code help you can provide?
Upvotes: 2
Views: 347
Reputation: 8064
I haven't spent any time watching into the Grouse algorithm, but I guess you could do well using a combination of STL containers (vectors, hashes, and so on) and custom classes, for your structures (images, rois, regions, and so on).
For example:
imageRoiHash(key=rowIndex, value=roi)
, or imageRoiHash(key=rowIndex, value=vector<roi>)
. I don't know if you can have one or more rois per image row.roiClass(bool found, TValue value)
. TValue
being an int, a string, or another class.
Then you can process your image, and get the rois in each row with hash[rowIndex].Or:
imageRoiList(std::vector<roi>)
, or imageRoiList(std::vector<std::vector<roi>)
. This is, a 2D structure where you keep the roi or rois per image row.Upvotes: 1