これは私が完全に理解していない機能であり、完全に理解したいと思っています:
/**
* Returns: the label of a vertex in the given image at location (x, y).
* 0 = unlabeled vertex at location (x, y)
* 1 = background label at location (x, y)
* 2 = object/foreground label at location (x, y)
*/
int getLabelAtVertexXY(IplImage* image, int x, int y) {
uchar* data = (uchar*) image->imageData + y * image->widthStep + 3 * x;
if (data[2] < 128 && data[1] < 128)
return 0;
else if (data[1] > data[2])
return 1; // TODO: data[1] holds probability in background starting at 128-255?
else
return 2;
}
画像の各ピクセルには 0、1、または 2 のラベルが付けられています。その情報はunsigned char
ポインタにどのように格納されていますdata
か?
unsigned char
は 0 から 255 までの数字を表すことができますが、 のどの部分がunsigned char
取得data[1]
されるのでしょうか?