塑形';二值图像matlab中的s帧a

塑形';二值图像matlab中的s帧a,matlab,Matlab,我有以下二进制图像: 我最终尝试的是: 有人有办法解决这个问题吗? 非常感谢 对于这个问题,我们假设字母是黑色背景(0)上的白色(1)。(即图像外部为黑色) 以下matlab脚本使用腐蚀、膨胀、填充和/或/或非逻辑操作组合工作: %This script assumes the input image is a binary bitmap image %Otherwise use: %BW = logical(BW); after loading graysca

我有以下二进制图像:

我最终尝试的是: 有人有办法解决这个问题吗?
非常感谢

对于这个问题,我们假设字母是黑色背景(0)上的白色(1)。(即图像外部为黑色)

以下matlab脚本使用腐蚀、膨胀、填充和/或/或非逻辑操作组合工作:

     %This script assumes the input image is a binary bitmap image
     %Otherwise use: 
     %BW = logical(BW); after loading grayscale image with BW = imread(filename); 

     BW = imread('img.bmp'); %read in the image
     figure
     imshow(BW) %show original image

     %for the outside edges
     BW2 = imfill(BW, 'holes'); %fill holes in letters
     BW3 = imerode(BW2, strel('disk',1));
     BW4 = BW2 & (~BW3); %outside boundary of letters (8 connected)
     figure
     imshow(BW4) %show outside edges

     %for the inside edges
     BW2 = imerode(BW3, strel('disk',1)); %erode filled letters again
     BW3 = ~(BW & BW2);  %logical AND operation of original image and doubly eroded filled letter image
     BW2 = ~imfill(BW3,1); %fill image with white (1), starting at 1,1 leaves
     BW3 = imfill(BW2, 'holes'); %fill inner holes
     BW2 = BW3 & (~BW2); %logical operation to isolate inner holes
     BW3 = imdilate(BW2,strel('disk',1))-BW2; %boundary of inner edges

     BW2 = BW3 | BW4; %logical OR operation to obtain inside and outside edges
     figure
     imshow(BW2) %final image

您可以尝试使用与非最大抑制一起使用。从第29页开始,这些可能对您也很有用。matlab中的几个
edge
检测器也很有用。只需查找
边缘
函数。配合
bwmorph
你应该能够解决一些问题。否则,您可能需要创建自己的过滤器,并使用
imdeplate
imerode
的组合以及专门设计的结构元素。鉴于您图像中的缺陷,我将重点寻找一种稳健的方法来填充字符,然后使用边缘检测器或形态学运算来找到边界。对损坏的图像应用边缘检测可能会拾取角色内部缺陷的边缘,这是您不希望看到的。