小编alv*_*tya的帖子

openCV - 在灰度图像上绘制颜色轮廓

我正在研究医学图像的分割算法,在此过程中,它必须在原始图像上显示不断变化的轮廓.
我正在使用灰度JPEG.为了显示轮廓,我使用drawContours函数,但我无法绘制颜色轮廓.我想在灰度图像上绘制一个红色轮廓,但它只显示为黑色或白色.
这是代码的一部分:

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);
Run Code Online (Sandbox Code Playgroud)

是否可以在灰度图像上显示颜色轮廓?
谢谢

opencv image colors contour grayscale

7
推荐指数
1
解决办法
2万
查看次数

理解Matlab中的DEL2函数,以便用C++编写代码

为了在c ++中编写DEL2 matlab函数,我需要了解算法.我已经设法为矩阵中不在边界或边缘上的元素编写函数.我已经看过几个关于它的主题并通过键入"edit del2"或"type del2"读取MATLAB代码,但我不理解为获得边框和边缘而进行的计算.

任何帮助将不胜感激,谢谢.

c++ matlab function

2
推荐指数
1
解决办法
1787
查看次数

标签 统计

c++ ×1

colors ×1

contour ×1

function ×1

grayscale ×1

image ×1

matlab ×1

opencv ×1