Length and width calculation

Asked

Viewed 63 times

-1

Hello, I’m developing an application in Octave, which is very similar to Mathlab and C, which calculates the height and width of an object, which in this case is a seed.

The program receives an input image and then binarizes. I would like to know how to calculate this distance, because I have researched a lot and I could not understand very well.

One of the questions is: How to find the two points in the image to measure the distance between them? Because like, in my thought I have to get to the "middle" of the object, the top and "go down" a line to the end of the object, that way I would have a line of pixels, that after performing a rule of three with another object of known size, I would get this information.

Grateful from now on.

  • What have you done so far?

  • I am in the process of acquiring the images. However, I was left with this doubt when I started thinking about the code.

  • What format is the image file?

  • The input image is in .jpg. Then I turn it black and white.

1 answer

1

If it’s a color image,

I = imread("minhaImagem.png");
img = I(1);
[width, height, colorDepth] = size(img);

disp(width); disp(height)

If it’s a monochromatic image,

I = imread("minhaImagem.bmp");
img = I(1);
[width, height] = size(img);

disp(width); disp(height)

If it’s an animated image,

I = imread("minhaImagem.gif");
img = I(1);
[width, height, colorDepth, timing] = size(img);

disp(width); disp(height)
  • Dear, what happens on line 2,3,4 ?

  • What do you mean? Isn’t it clear? He takes the first item from I and extracts the dimensions of this item.

  • https://octave.sourceforge.io/octave/function/imread.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.