Height and width of an image

Hi, is it possible to find the height and width of the object inside an image? I had attached an image with white and black line to find width and height value

2 Commenti

KSSV
KSSV il 8 Ott 2018
Modificato: KSSV il 8 Ott 2018
Read about imdistline, regionprops.
can it be 2 value? one horizontally and one is vertically?

Accedi per commentare.

 Risposta accettata

ANKUR KUMAR
ANKUR KUMAR il 8 Ott 2018
Try this,
A=imread('testing.jpg');
AA=rgb2gray(A);
len=max(arrayfun(@(x) length(find(AA(:,x)~=255)),1:800))
bred=max(arrayfun(@(x) length(find(AA(x,:)~=255)),1:800))

9 Commenti

is it possible to show the imdistline?
Yes. It's possible.
h = imdistline(gca,[x1,y1],[ x2,y2]);
Just give the coordinates in the above in place of x1,y1,x2 and y2.
If you are feeling difficulty in setting the x1,y1,x1 and y2, use this and drag the line as per your wish.
h = imdistline(gca);
but can i save the value after i drag the line?
Why you wish to save. The program gives automatically that value.
Make sure, you are using imshow(A) before using imdistline.
The value over the dragged line and the resulted value len=max(arrayfun(@(x) length(find(AA(:,x)~=255)),1:800)) are same.
okok, is it possible to drag the distline in matlab gui?
Yes.
is it I straight used in the axes or?
Note:
nnz(something)
is simpler and a lot faster to compute than:
length(find(something))

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by