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

7 visualizaciones (últimos 30 días)
Tuck Wai Yip
Tuck Wai Yip el 9 de Mayo de 2021
Editada: Tuck Wai Yip el 10 de Mayo de 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.

Respuesta aceptada

Image Analyst
Image Analyst el 9 de Mayo de 2021
Editada: Image Analyst el 9 de Mayo de 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 comentario
Tuck Wai Yip
Tuck Wai Yip el 10 de Mayo de 2021
Editada: Tuck Wai Yip el 10 de Mayo de 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!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by