我是 MATLAB 新手,我想知道我可以从指定边界内提取图像的一部分,基于区分颜色(在我的情况下为红色边界),该函数,首先跟踪图像的边界,然后它提取该特定边界内的图像部分。我附上了我的图像(人头图像),我想从头部提取大脑部分,图像的其他部分应该被忽略。我试图找到边缘,使用以下代码(它显示 1 表示边界,0 表示无边界),但它只显示 0。
任何帮助将不胜感激。
附上的 PS 图像显示了原始图像和带边界的图像....代码将处理带边界的图像,并将提取位于该边界内的图像部分。
下面是我试过的代码:
BW = edge(x)
BW = edge(x,'sobel')
BW = edge(x,'sobel',thresh)
BW = edge(x,'sobel',thresh,direction)
[BW,thresh] = edge(x,'sobel',...)
BW = edge(x,'prewitt')
BW = edge(x,'prewitt',thresh)
BW = edge(x,'prewitt',thresh,direction)
[BW,thresh] = edge(x,'prewitt',...)
BW = edge(x,'roberts')
BW = edge(x,'roberts',thresh)
[BW,thresh] = edge(x,'roberts',...)
BW = edge(x,'log')
BW = edge(x,'log',thresh)
BW = edge(x,'log',thresh,sigma)
[BW,threshold] = edge(x,'log',...)
BW = edge(x,'zerocross',thresh,h)
[BW,thresh] = edge(x,'zerocross',...)
BW = edge(x,'canny')
BW = edge(x,'canny',thresh)
BW = edge(x,'canny',thresh,sigma)
[BW,threshold] = edge(x,'canny',...)