I am trying to extract an object from a paper currency image. On the original image I applied sobel edge detection. Here is the image:
My question is in the following cropped image I want to have only the number 100 displayed with out the other noises. How can I do that please?
The code I used so far is:
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);
For completeness, the original image:
Use a Gaussian filter to clean up the noise before applying the edge detector:
% 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);
This results in a much cleaner 100 image
You could also use a Canny edge detector instead of the Sobel transform.
Edge1c = edge(Note1,'canny', [0.2, 0.4] , 3.5);
sub_Note1c = imcrop(Edge1c,rect_Note1);
figure(7), imshow(sub_Note1c);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With