How to find the size of the handwritten word in an image?

1 回表示 (過去 30 日間)
Poornima Gokhale
Poornima Gokhale 2015 年 12 月 19 日
コメント済み: Meghashree G 2015 年 12 月 23 日
When a word is given I want to find the size of it (not the width) i.e., if a word like 'hello' is given its approximate size should be found out considering all the upperzone letters like 'l' and middle zone letters like 'e'.I have tried the bounding box but it is not efficient because it will give the maximum possible height, but i want the average height. Please help me with the code.

回答 (2 件)

Image Analyst
Image Analyst 2015 年 12 月 19 日
To get the average height, you'll have to scan across the image column by column using find to find the first black pixel and the last black pixel
for col = 1 : size(grayImage, 2)
topRow(col) = find(grayImage < someThreshold, 1, 'first');
bottomRow(col) = find(grayImage < someThreshold, 1, 'last');
height(col) = bottomRow(col) - topRow(col);
end
meanHeight = mean(height);
  5 件のコメント
Poornima Gokhale
Poornima Gokhale 2015 年 12 月 21 日
Thank You

サインインしてコメントする。


harjeet singh
harjeet singh 2015 年 12 月 21 日
編集済み: harjeet singh 2015 年 12 月 21 日
may be this code will help you
clear all
close all
warning off
clc
img1=imread('word.png');
[m n x]=size(img1);
figure(1)
imshow(img1)
drawnow
img2=img1(:,:,1)<80;
img2=bwareaopen(img2,50);
figure(2)
imshow(img2)
[lab,num]=bwlabel(img2);
figure(1)
imshow(img1)
hold on
for i=1:num
[r,c]=find(lab==i);
plot([mean(c) mean(c)],[min(r) max(r)],'r');
text(mean(c)+5,m,num2str(max(r)-min(r)));
hold on
end
  7 件のコメント
Meghashree G
Meghashree G 2015 年 12 月 23 日
oh ok sir .thanks a lot :) @image analyst ,sir thank you for you also :)

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by