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

3 ビュー (過去 30 日間)
Tuck Wai Yip
Tuck Wai Yip 2021 年 5 月 9 日
編集済み: Tuck Wai Yip 2021 年 5 月 10 日
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 Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by