Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How to fit object in image to a shape in Matlab?
In Matlab, I've figured out how to extract specific images from a picture and measure their area. However, these images are irregular shaped and counting pixels are not very accurate. How would one take specific objects from the whole picture and fit them to a shape (e.g. an ellipse or a rectangle)?
1 Answer
- ooorahLv 65 years ago
What do you mean by "fit them to a shape"? Just so my terminology is clear, you have a partial-image that contains the portion of the total image that you are interested in. Do you want to crop off any part of the partial image that falls outside of a predefined ellipse or rectangle? Or are you trying to fit a rectangle or ellipse to the partial-image, and use that shape for various calculations? Or something else entirely?
Whichever way you're trying to do, you may find the "regionprops" function useful. It provides information about regions defined within the image. Not sure if you were already using this to find area, or if you were "counting pixels" in some other way.
Let me know what you would like, what's the input and what's the output, and I'll see if I can get more specific. Give me a thumbs up once you've commented or edited your post so that I get notified and can check this again.
EDIT:
Here, this is probably the best demonstration for using "regionprops" to assist with fitting and visualizing ellipses on an image:
Source(s): regionprops: http://www.mathworks.com/help/images/ref/regionpro...