Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Trying to determine value of pixels found at certain coordinates

So I found coordinates of pixels based on blob detection, and I need to determine whether or not these pixels are within a certain hsv range. I have done this before with nested for loops successfully, but I can't figure out how to feed the pixels both coordinates instead of just going through every single pixel in the picture.

vector<Point2f> coor;
//populate vector
Vec3b* hsv = output.ptr<Vec3b>(img.rows, img.cols);
for(int I = 0; I < coor.size(); I++) {
   Point2f j = coor[I];
   uchar h = hsv[j][2];
   uchar s = hsv[j][1];
   uchar v = hsv[j][0];
   //check ranges
}

My errors basically just say there's no match for these operands (related to the j). I have had no luck with google or my own ideas.

Trying to determine value of pixels found at certain coordinates

So I found coordinates of pixels based on blob detection, and I need to determine whether or not these pixels are within a certain hsv range. I have done this before with nested for loops successfully, but I can't figure out how to feed the pixels both coordinates instead of just going through every single pixel in the picture.

vector<Point2f> coor;
//populate vector
Vec3b* hsv = output.ptr<Vec3b>(img.rows, img.cols);
for(int I = 0; I < coor.size(); I++) {
   Point2f j = coor[I];
   uchar h = hsv[j][2];
   uchar s = hsv[j][1];
   uchar v = hsv[j][0];
   //check ranges
}

My errors basically just say there's no match for these operands (related to the j). I have had no luck with google or my own ideas.

Update: I have fixed it. Proper context is:

int h = img.at<Vec3b>(j.y, j.x).val[2];
int s = img.at<Vec3b>(j.y, j.x).val[1];
int v = img.at<Vec3b>(j.y, j.x).val[0];