how to calculate width and length of binary image?

 Risposta accettata

You can use the size() function:
[theLength, width] = size(binaryImage);
The first return argument, theLength, is the number of rows (the height), and the second output argument, width, is the number of columns.
As an aside, don't use length as the name of a variable since it's the name of a built-in function.

8 Commenti

If you want the width and height for each blob in the binary image, then you'll have to use regionprops as shown in my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
Thanx sir
But it returns the size of the whole image wat I gav.. But I need length width of the binary object in my image...
Please see my demo. It will find the two most distant points in any arbitrarily shaped binary blob, shown by the red line in the image below. It also finds the length inside the blob of the perpendicular mid-point of the longest line, shown in magenta. Feel free to adapt as needed.
Thanx for your help sir.... But there exist an error while executing this code.. nume1 is undefinedundefined function for logical plz say me wat it represents
There is no error in my code - in fact I just copied and pasted and it worked just fine. You must have changed it and broke it. It looks like you wrote nume1 (with a one) instead of numel (ending in a lower case "L"). Correct your code and try again. Post your code if you have problems with your code.
ok sir i will check this...
sir but this gives wrong width for my image sir...
my image is in this link http://labs.fme.aegean.gr/decision/downloads in this link under martin2003 zip file New database pictures\normal superficiel cells are my images sir... plz try it

Accedi per commentare.

Più risposte (1)

Matt J
Matt J il 18 Ott 2014
Modificato: Matt J il 18 Ott 2014
The size() command?
[Width,Length]=size(binaryImage);

Categorie

Prodotti

Richiesto:

sou
il 18 Ott 2014

Commentato:

sou
il 20 Ott 2014

Community Treasure Hunt

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

Start Hunting!

Translated by