use*_*037 5 matlab image-processing edge-detection image-segmentation
我试图从纸币图像中提取对象.在原始图像上我应用了sobel边缘检测.这是图像:

我的问题是在下面的裁剪图像中,我希望只显示数字100而不显示其他噪音.我该怎么办?

我到目前为止使用的代码是:
close All;
clear All;
Note1 = imread('0001.jpg');
Note2 = imread('0007.jpg');
figure(1), imshow(Note1);
figure(2), imshow(Note2);
Note1=rgb2gray(Note1);
Note2=rgb2gray(Note2);
Edge1=edge(Note1,'sobel');
Edge2=edge(Note2,'sobel');
figure(5), imshow(Edge1),title('Edge sobel1');
figure(6), imshow(Edge2),title('Edge sobel2');
rect_Note1 = [20 425 150 70];
rect_Note2 = [20 425 150 70];
sub_Note1 = imcrop(Edge1,rect_Note1);
sub_Note2 = imcrop(Edge2,rect_Note2);
figure(7), imshow(sub_Note1);
figure(8), imshow(sub_Note2);
Run Code Online (Sandbox Code Playgroud)
为完整起见,原始图像:

在应用边缘检测器之前使用高斯滤波器清除噪声:
% Create the gaussian filter with hsize = [5 5] and sigma = 3.5
G = fspecial('gaussian',[7 7], 3.5);
Note1f = imfilter(Note1,G,'same');
Edge1f=edge(Note1f,'sobel');
sub_Note1f = imcrop(Edge1f,rect_Note1);
figure(6), imshow(sub_Note1f);
Run Code Online (Sandbox Code Playgroud)
这会产生更干净的 100 图像

您还可以使用 Canny 边缘检测器来代替 Sobel 变换。
Edge1c = edge(Note1,'canny', [0.2, 0.4] , 3.5);
sub_Note1c = imcrop(Edge1c,rect_Note1);
figure(7), imshow(sub_Note1c);
Run Code Online (Sandbox Code Playgroud)
