MATLAB - Calculate distance/perimeter of an object in 2D image

In summary, The conversation discusses the use of MATLAB to calculate the size of an object in an image, specifically the perimeter of a tree trunk. The problem is finding a way to do this with only front and side view images from one camera. Suggestions include using 3D calculations, finding the length of the trunk from a front view image, or using a different software if necessary. However, without a known reference length, it may not be possible to accurately determine the size.
  • #1
Ping Ong
2
0
Hi, I want to find out how thick/big/fat is the object in the image.

For example, there is a tree in the image(photograph), I want to use MATLAB to calculate how big the tree trunk is.
Problem: Find out the perimeter of trunk as shown in the first picture (named "perimeter.PNG". attached here.

1) Can I use 3D calculation with front view and side view images only(Only use 1 camera)?
2) Or find out the length of trunk from front view ( second image, named "length.PNG") and combine with other algorithm?
3) If the methods I suggested above are not possible, any possible solutions?

p/s: will use matlab, if MATLAB can't do these,any suggestion on software?

Will very appreciate on your suggestions.
Thanks in advance!:smile:
 

Attachments

  • perimeter.PNG
    perimeter.PNG
    15 KB · Views: 658
  • length.PNG
    length.PNG
    2.3 KB · Views: 645
Physics news on Phys.org
  • #2
Without some known reference length, I don't see how this can be done. You might as well ask MATLAB to guess your height and weight.
 
  • #3
SteamKing said:
Without some known reference length, I don't see how this can be done. You might as well ask MATLAB to guess your height and weight.

How if height is given or another object in the image with known size?? Any solution? Thanks
 
Last edited:

1. How can I calculate the distance between two points in a 2D image using MATLAB?

To calculate the distance between two points in a 2D image using MATLAB, you can use the built-in function "pdist2". This function takes in two arrays of coordinates and returns the Euclidean distance between each pair of points. You can also use the "norm" function to calculate the distance between two points using their x and y coordinates.

2. Can I calculate the perimeter of an irregularly shaped object in a 2D image using MATLAB?

Yes, you can calculate the perimeter of an irregularly shaped object in a 2D image using MATLAB. First, you can use the "bwperim" function to create a binary perimeter image of the object. Then, you can use the "regionprops" function to calculate the perimeter of the object based on the boundary pixels in the perimeter image.

3. How do I convert the distance/perimeter values from pixels to a physical unit in MATLAB?

To convert the distance or perimeter values from pixels to a physical unit, you need to know the scale of the image in terms of pixels per unit (e.g. pixels per inch). You can then multiply the distance or perimeter values by this scale to obtain the measurements in the desired physical unit.

4. I have a 3D image, can I still use MATLAB to calculate the distance/perimeter of an object?

Yes, you can use MATLAB to calculate the distance or perimeter of an object in a 3D image. You can use the "pdist" function for 3D points, which calculates the Euclidean distance between each pair of points. For calculating the perimeter, you can use the "bwperim" function to create a binary perimeter image and then use "regionprops" to calculate the perimeter based on the boundary pixels.

5. Are there any other useful MATLAB functions for calculating distances or perimeters in images?

Yes, there are other useful MATLAB functions for calculating distances or perimeters in images. These include "imdistline" for interactive measurement of distances in an image, "bwdist" for calculating the distance of each pixel in a binary image to the nearest non-zero pixel, and "perimeter" for calculating the perimeter of a binary image using the Moore-Neighbor tracing algorithm.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • Astronomy and Astrophysics
Replies
1
Views
1K
Back
Top