Could help somebody please ? I have an image after Canny detector, the type is 8UC1, when i want to access to the values, cout gives to me ? (Test Canny�), so my code is following:
Mat src;
/// Load an image
src = imread( argv[1] );
if( !src.data )
{ return -1; }
Mat src_gray(src.size[1],src.size[2],CV_8U,0);
//some parameters
int edgeThresh = 1;
//int lowThreshold;
int lowThreshold = 100;
int const max_lowThreshold = 100;
int ratio = 3;
int kernel_size = 3;
//char* window_name = "Edge Map";
cvtColor( src, src_gray, CV_BGR2GRAY );
Mat detected_edges;
/// Reduce noise with a kernel 3x3
blur( src_gray, detected_edges, Size(3,3) );
///Canny edge detection
Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size );
for (unsigned int i=0;i<detected_edges.size[1];i++){
for (unsigned int j=0;j<detected_edges.size[1];j++) {
if (detected_edges.at<unsigned char>(i,j)!=0)
cout<<"Test Canny"<<detected_edges.at<unsigned char>(i,j)<<endl;
}
}
When I change in short, i.e. (i,j), it gives to me value between -256 and 255. I do not understand why with the type 8UC1, i need to use short and is it correct to use short ? (To verify surely which type I have, I used this link How to find out what type of a Mat object is with Mat::type() in OpenCV) Thanks.