MATLAB Answers

How should I denoise the image to extract the characters from the image?

1 view (last 30 days)

Answers (1)

Ramnarayan Krishnamurthy
Ramnarayan Krishnamurthy on 22 Sep 2017
A possible approach to solve the above problem is as follows:
% Read in the image
Iin = rgb2gray(imread('test.png'));
% Bottom Hat filtering to enhance the "valleys"
I1 = imbothat(Iin,strel('diamond',5)),strel('diamond',1);
% Opening with a horizontal element
I2 = imopen(I1,strel('arbitrary',[1 1 1]));
% Opening with a vertical element
I3 = imopen(I2,strel('arbitrary',[1 1 1]'));
% Binarize
I4 = ~imbinarize(I3,.8);
imshow(I4)
I believe that the OCR reader would be robust enough to read in these alphabets now.
Another approach specific to this image would involve addressing the 2 conspicuous noises: 1) Salt and pepper noise 2) Random lines
Removing the salt and pepper noise is pretty simple using a median filter.
imshow(medfilt2(Iin))
Removing the lines may be slightly more complex. Consider using the hough transform to locate and remove the undesired lines. The example describes how to find the houghlines in an image:
You would now have to remove these lines and then perform basic operations to have it in the desired format.
Hope this helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by