Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
How to Calculate Original Size of Objects in Digital Image by Matlab

How to Calculate Original Size of Objects in Digital Image by Matlab

Ratings: (0)|Views: 1,455|Likes:
Published by Jans Hendry

More info:

Published by: Jans Hendry on Dec 09, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less

11/09/2013

pdf

 
[digital image processing] December 9, 2012
 
[janshendry@gmail.com] Page 1
HOW TO CALCULATE ORIGINAL SIZE OF OBJECTSIN DIGITAL IMAGE BY MATLAB
In this article, I will elaborate how do we calculate size of objects in digital image by Matlab. Thissize is the original one, which is measure in cm. We actually do not need sophisticated algorithm todo that. But when the combination of objects get complicated, we are gonna need some algorithm tosolve. Why do we need such algorithm? To extract the objects from background, then distinguisheach of them and decide what kind of objects they are.I have prepared some images that contain an object which is square and use these images as input to program. Below are steps I arrange in order to accomplish our task:-
 
Read the image(s)-
 
Convert to binary file-
 
If the detected objects are not white colored then inverse it -
 
If the object more than one then distinguish them and then process it individually-
 
Get width and height of the object then divide it with value of resolution. One can take thevalue of image resolution by using IMFINFO from matlab.-
 
Convert size of object to cm if resolution in inch or let it as it is if already in cm.Okay, based on the steps I mention above I already made a program to fulfill the task. Lets take alook.
clearall;
 
closeall;
 
clc;
 
%% start
 
filename ='back.jpg';% resolusi = 96
 
% filename = 'back2.jpg'; % resolusi = 200
 
% filename = 'back3.jpg'; % resolusi = 300
 
% filename = 'back4.jpg';
 
I = imread(filename);
 
info = imfinfo(filename);
 
thres = graythresh(I);
 
I2 = ~(im2bw(I, thres));
 
cmp = bwconncomp(I2);
 
S = regionprops(cmp, {'BoundingBox'});
 
x = S.BoundingBox(3);
 
 
[digital image processing] December 9, 2012
 
[janshendry@gmail.com] Page 2
y = S.BoundingBox(4);
 
res = info.ResolutionUnit;
 
resX = info.XResolution;
 
resY = info.YResolution;
 
ifstrcmp(res,'Inch')
 
lebar = 2.54 * x / resX;
 
tinggi = 2.54 * y / resY;
 
else lebar = x / resX;
 
tinggi = y / resY;
 
end
 
fprintf('X Resolution = %.2f %s\n', resX, res);
 
fprintf('Y Resolution = %.2f %s\n', resY, res);
 
disp('Size of Object:');
 
fprintf('Width = %.2f cm\n', lebar);
 
fprintf('Height = %.2f cm\n', tinggi);
 
%% end
 
When I run this program, I get results below: I have put an square object in an image, size of theobject is 2 cm x 2 cm. Now, we ask Matlab to calculate it by using steps we made above.Result 
 
[digital image processing] December 9, 2012
 
[janshendry@gmail.com] Page 3
Result Result 

Activity (3)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
leardpan liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->