level 1
RKin毁
楼主
目标:我是在ROI图像中寻找出轮廓之后,希望还原到原图上;但是原图上连接都是从原点开始的,请问有人知道为什么吗?该怎么解决?以下是效果图以及部分代码

VectorOfVectorOfPoint use_contours = new VectorOfVectorOfPoint();
//寻找轮廓
CvInvoke.FindContours(imgBord, contours, null, RetrType.External, ChainApproxMethod.ChainApproxSimple);
int[] contourL = new int[imgScr.Height];
int[] contourH = new int[imgScr.Width];
for (int i = 0; i < use_contours.Size; i++)
{
Rectangle rect = CvInvoke.BoundingRectangle(use_contours[i]);
CvInvoke.Rectangle(mask, rect, new MCvScalar(0, 255, 0), 1);
//在原始图像上标记提取结果
//VectorOfPoint use_contour = use_contours[i];
//Point[] vp = use_contour.ToArray();
// CvInvoke.AddWeighted(imgScr, 0, use_contours, 0, 0, imgScr);
for (int j = 0; j < use_contours[i].Size; j++)
{
contourL[j] = use_contours[i][j].X + (int)(0.2 * imgScr.Width);
contourH[j] = use_contours[i][j].Y + (int)(0.6 * imgScr.Height);
CvInvoke.Line(imgScr, new Point(contourL[j], contourH[j]), new Point(contourL[j + 1], contourH[j + 1]), new MCvScalar(0, 255, 0), 1);
}
}
2018年03月22日 10点03分
1

VectorOfVectorOfPoint use_contours = new VectorOfVectorOfPoint();//寻找轮廓
CvInvoke.FindContours(imgBord, contours, null, RetrType.External, ChainApproxMethod.ChainApproxSimple);
int[] contourL = new int[imgScr.Height];
int[] contourH = new int[imgScr.Width];
for (int i = 0; i < use_contours.Size; i++)
{
Rectangle rect = CvInvoke.BoundingRectangle(use_contours[i]);
CvInvoke.Rectangle(mask, rect, new MCvScalar(0, 255, 0), 1);
//在原始图像上标记提取结果
//VectorOfPoint use_contour = use_contours[i];
//Point[] vp = use_contour.ToArray();
// CvInvoke.AddWeighted(imgScr, 0, use_contours, 0, 0, imgScr);
for (int j = 0; j < use_contours[i].Size; j++)
{
contourL[j] = use_contours[i][j].X + (int)(0.2 * imgScr.Width);
contourH[j] = use_contours[i][j].Y + (int)(0.6 * imgScr.Height);
CvInvoke.Line(imgScr, new Point(contourL[j], contourH[j]), new Point(contourL[j + 1], contourH[j + 1]), new MCvScalar(0, 255, 0), 1);
}
}