Is there a way to make the word in the image clearer?

3 vues (au cours des 30 derniers jours)
Tuck Wai Yip
Tuck Wai Yip le 9 Mai 2021
Modifié(e) : Tuck Wai Yip le 10 Mai 2021
w = 20;
h = 20;
blankImage= 255*ones(w,h,3,'uint8');
position_x = (w+1)/2;
position_y = (h+1)/2;
font_start = 10;
font_end = 16;
num_fontsA = font_start:2:font_end;
numImagesA = length(num_fontsA)
A = cell(1, numImagesA);
for i=1:numImagesA
for font_size = num_fontsA(i)
img= insertText(blankImage,[position_x position_y],'A','Font','Times New Roman','FontSize',font_size,'TextColor','black','BoxColor','w','BoxOpacity',0,'AnchorPoint','Center');
img= rgb2gray(img);
A{i} = img;
subplot(2,2,i);
imshow(A{i});
axis on;
title("A with font size " + font_size);
end
end
I get this "A" with different font size, but it seems a little blur from the edge since I need to OCR on it later on after applying different standard deviation of normal noise.Did I need to make the word clearer first before doing next step? My next step is separate the A with the background ,then need to identify which pixel belongs to A or background which I will ask in another post.Thank you.

Réponse acceptée

Image Analyst
Image Analyst le 9 Mai 2021
Modifié(e) : Image Analyst le 9 Mai 2021
Simply use images with more resolution - more elements. A 20x20 image is too small to get good resolution of a binary image made from lines.
% Demo by Image Analyst.
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
workspace; % Make sure the workspace panel is showing.
w = 200;
h = 200;
blankImage= 255*ones(w,h,3,'uint8');
position_x = (w+1)/2;
position_y = (h+1)/2;
font_start = 50;
font_end = 200;
num_fontsA = round(linspace(font_start, font_end, 4))
numImagesA = length(num_fontsA)
A = cell(1, numImagesA);
for i=1:numImagesA
for font_size = num_fontsA(i)
img= insertText(blankImage,[position_x position_y],'A','Font','Times New Roman','FontSize',font_size,'TextColor','black','BoxColor','w','BoxOpacity',0,'AnchorPoint','Center');
img= rgb2gray(img);
A{i} = img;
subplot(2,2,i);
imshow(A{i});
axis on;
title("A with font size " + font_size);
end
end
  1 commentaire
Tuck Wai Yip
Tuck Wai Yip le 10 Mai 2021
Modifié(e) : Tuck Wai Yip le 10 Mai 2021
Oh, thanks for your suggestion .So it is about the empty cell of the image for the letter. Font size 50 is quite big for me, maybe I will trial and error myself until getting the output resolution that I desired with smaller font size and image resolution. Thank you very much on solving my doubts.It solves all my problem before going to next step,extract the background and foreground.Hope you have a nice day!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by