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

4 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2021-5-9
编辑:Image Analyst 2021-5-9
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 个评论
Tuck Wai Yip
Tuck Wai Yip 2021-5-10
编辑:Tuck Wai Yip 2021-5-10
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!!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Computer Vision Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by