MATLAB: How to perform Spatial segmentation

Image Processing Toolbox

I had to replace "bwareafilt" command to "bwareaopen" in order for the code to work ...how much difference does it make or is it the same command with different names in different versions ?
  • 3) Is the histogram only performed for gray images or could it be RGB images do?
The camera is a in a fixed position on a clamp ,does that mean the magnification will remain constant ??
How to increase the exposure in an image to reach 200 gray levels ?

Best Answer

  1. You can, though it will be slower, and may be noisier since the green channel is usually the best and most accurate channel because there are twice as many green pixels in a camera as either red or blue pixels.
  2. bwareafilt() is newer and lets you say how many blobs you want. bwareaopen() makes you say what size you want. If you know the sizes in advance, then you can get either to do the same thing.
  3. I did the histogram of the gray scale image. If you want, you could do the histogram of red, green, and blue separately. You'd probably want to use histcounts() and plot() if you do it that way because 3 bar charts on the graph simultaneously can get kind of confusing.
  4. If you know for a fact that your lens focus and working distance never changes, then you can use a fixed spatial calibration factor.
  5. Put the camera in manual mode and set the exposure time and aperture so that your image is bright enough. Check it's histogram.
  6. I thresholded it to get the white disk, and to get the black thing. But when getting black stuff, there was a bunch of other clutter because you don't have good control over your imaging setup. Like I said, use black velvet behind everything and the solution could be simpler. So I ANDed the white disc with the black regions so that I only get black things that were also within the filled white disc region.
  7. I believe the final binary image has only the flywheel, so yes, the area and diameter or whatever else you want to measure will be only of that flywheel region. If you know it's round, you could use bwconvhull() to make the perimeter smoother and rounder.
Related Question