1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| void convert (*IplImage binarized_image) {
IplImage* hsv_image = cvCreateImage (cvGetSize (binarized_image), binarized_image, 3);
int h = 0;
for (int x=0;x<binarized_image->width;x++) {
for (int y=0;y<binarized_image->height;y++) {
if (((uchar *)(binarized_image->imageData + y*binarized_image->widthStep))[x] == 255) {
CvScalar ddd = cvGet2D (hsv_image, y, x);
//if (ddd.val[0] == h)
CvScalar colour = cvScalar (h, 255, 255);
cvSet2D (hsv_image, y, x, colour);
voisins (hsv_image, x, y, colour); // donne la couleur "colour" au pixel (x,y) et à tous ses voisins blancs
//h = (h+10) % 180;
} else {
cvSet2D (hsv_image, y, x, cvScalar (0));
}
}
}
//cvCvtColor (hsv_image, hsv_image, CV_HSV2BGR);
cvShowImage ("maskPerso", hsv_image);
cvReleaseImage (&hsv_image);
} |
Partager