I'm working on a segmentation algorithme for medical images and during the process it must display the evolving contour on the original image.
I'm working with greyscale JPEG. In order to display the contours I use the drawContours function but I can't manage to draw a color contour. I would like to draw a red contour on the greyscale image but it only appears black or white.
Here is the section of the code:
Mat_<uchar> matrix = imread(path,0);
int row = matrix.rows;
int col = matrix.cols;
Mat_<uchar> maskInter(row,col);
for (int i=0; i<row; i++)
for (int j=0; j<col; j++)
{
if ((double)matrix(i,j) <0)
{maskInter(i,j)=255;}
else
{maskInter(i,j)=0;}
};
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
Mat mat_out = maskInter.clone();
findContours( mat_out, contours, hierarchy, CV_RETR_TREE , CHAIN_APPROX_SIMPLE);
drawContours( img, contours, -1, RGB(255,0,0),1.5,8,hierarchy,2,Point());
namedWindow(title);
moveWindow(title, 100, 100);
imshow(title, img);
waitKey(0);
Is it possible to display a color contour on a greyscale image?
Thanks