here's my code.... when i execute it... given any arbit image... it always gives result as an entirely black or entirely white image... is there any problem with the iteration?
int main(void)
{
int i=0,j=0,height=0,width=0,step=0,k=0;
Mat img_hsv,img_rgb,red_blob,blue_blob;
//reading image... rgb format(default)... CV_8U3C
img_rgb = imread("pic.png",1);
//converting rgb image to hsv format for applying further operations
cvtColor(img_rgb,img_hsv,CV_BGR2HSV);
//defining the various component values or rather the pointer to those
//components of HSV format... hue, sat and value
uchar img_h=*(img_hsv.data+i*img_hsv.step+j*img_hsv.elemSize());
uchar img_s=*(img_hsv.data+i*img_hsv.step+j*img_hsv.elemSize()+1);
uchar img_v=*(img_hsv.data+i*img_hsv.step+j*img_hsv.elemSize()+2);
//naming window to be displayed
//for(i=0;i<1000;i++){j=i;cout<<img_h;if(img_h==170)cout<<"yesss";}
namedWindow("win1", CV_WINDOW_AUTOSIZE);
Mat img_bw(img_hsv.rows,img_hsv.cols,CV_8U);
imshow("win1", img_hsv);
//applying threshold and hence applying conversions
//by iterating over the entire image//
for(i=0;i<img_hsv.rows;i++){
for(j=0;j<img_hsv.cols;j++){
if((img_h>120)) && (img_s>150 || img_s<25) && (img_v>150))
*(img_bw.data+i*img_bw.step+j*img_bw.elemSize())=255;
else *(img_bw.data+i*img_bw.step+j*img_bw.elemSize())=0;
}
}
imshow("win1", img_bw);
thanks for the reply in advance!!!