filtering out letters in an image

6 次查看(过去 30 天)
kandlev
kandlev 2020-11-18
For %A, I only showed all the periods.
For %B, I only showed all the i's and j's
For %C, I want to only show all the o's
For %D, I want to only show all the p's
I'm having a lot of trouble with C and D where I can't figure out how to only show the o's and p's
Please only suggest morphological operations, that's what I know right now.
originalBW = imread('text.png');
originalBW = logical(originalBW);
figure;
imshow(originalBW);
se1 = strel('square',9);
B1 = imerode(originalBW, se1);
B2 = imreconstruct(B1, originalBW);
C1 = logical(originalBW - B2);
C2 = bwareafilt(originalBW,[10,15]);
figure
imshow(C2);
%B
SE1 = strel('rectangle', [15,1]);
dilateBW = imdilate(C1, SE1);
reconBW = imreconstruct(dilateBW, originalBW);
BW2 = logical(reconBW-C1);
dilateBW2 = imdilate(BW2, SE1);
C2 = imreconstruct(dilateBW2, originalBW);
figure;
imshow(C2);
%C
BW3 = imfill(originalBW, 'holes');
SE2 = strel('disk', 4);
BW4 = imerode(BW3, SE2);
C3 = imreconstruct(logical(BW4),originalBW);
figure;
imshow(C4);
%D
C4 = bwareafilt(C3,12);
figure;
imshow(C4);

回答(1 个)

Manas Meena
Manas Meena 2021-3-25
To filter out and detect specific letters from a binary image you'll need to define characteristics that define the particular letter you are interested in.
Please refer to the following link for the same

Community Treasure Hunt

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

Start Hunting!

Translated by