Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 从给定图像获取sub cv::Mat,以便_Algorithm_Opencv_Image Processing - Fatal编程技术网

Algorithm 从给定图像获取sub cv::Mat,以便

Algorithm 从给定图像获取sub cv::Mat,以便,algorithm,opencv,image-processing,Algorithm,Opencv,Image Processing,我处理了一个返回Mat的图像,比如: [ [ 0, 0, 255, 255, 255, 0, 0, 0], [ 0, 0, 0, 255, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 255, 255, 0], [ 0, 0, 0, 0, 0, 255, 255, 0], [ 0, 0, 0, 0, 0, 0, 0, 0

我处理了一个返回Mat的图像,比如:

[
[ 0, 0, 255, 255, 255, 0, 0, 0],
[ 0, 0, 0, 255, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 255, 255, 0],
[ 0, 0, 0, 0, 0, 255, 255, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0]
]
是否有任何分段功能可以帮助我单独分离? 如果不是这样,最好的方法是什么

i、 例如,如果我做了我的部分(Mat a,0)应该返回

[
[ 0, 0, 255, 255, 255, 0, 0, 0],
[ 0, 0, 0, 255, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0]
]
然后我的部分(Mat a,1)将返回

[
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 255, 255, 0],
[ 0, 0, 0, 0, 0, 255, 255, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0]
]
我认为连续255个像素是一个块。现在我想迭代或处理这些块。。。因为矩阵中可以形成多个块。

可以使用等高线

findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

链接到

很难说出你的问题是什么。你想“单独隔离”什么?@Aurelius我有一组块。。。我认为连续的“255”像素是一个块…可以有n个这样的块。。。我想把他们隔离起来他们知道了。。。您可以使用轮廓…:D:D查找轮廓->绘制轮廓确实有效:D