Is there a way to make the word in the image clearer?
5 次查看(过去 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.
0 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!