how to perform Spatial segmentation ?

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 ?

 Akzeptierte Antwort

Image Analyst
Image Analyst am 26 Mär. 2016

2 Stimmen

  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.

4 Kommentare

You need to put it into a loop where you call getsnapshot() from a live video stream, and then AnalyzeSingleImage() where you do the analysis on the snapshot that you just captured. This would include storing the result from that image into an array.
for k = 1 : 1000 % or whatever
thisImage = getsnapshot();
diameters(k) = AnalyzeSingleImage(thisImage);
end
The snapped image can be color or grayscale - it doesn't matter. But the analysis we decided on converts the image to grayscale as part of the analysis. So don't worry about it - it will work.
Aitzaz
Aitzaz am 26 Mär. 2016
Bearbeitet: Aitzaz am 6 Apr. 2016
is there any link or a video i could use to learn more regarding this ? ....i did look into a video on mathworks where a guy was performing image processing to alert the user of an intruder and the way he did it was he basically created an algorithm for the detection ( which i think is made successfully for the flywheel) and then he made this algorithm as a function and then called this function in another file in which as u suggested, i think he took a snapshot from live video and worked on from there .
  • The question is do i write the code for live video in the same script or is there another way to do this ?
Thank you !
Image Analyst
Image Analyst am 26 Mär. 2016
You can just do like I already showed you. Why does it need to be a video anyway? What happens if your hand gets in the way while you're switching out flywheels, and it totally messes up the analysis? I think you should just do it on still images.
After you capture each snapshot, you can take the mean of the whole image
theMean = mean2(grayImage);
If the mean is way different than usual, then something like a hand has come into the field of view.
What I don't understand is, if your disk is spinning, and the flywheel is the center part, then how are you going to change the flywheels while the whole contraption is spinning? Why is it spinning in the first place? If it has to spin, like you're monitoring some motor or something, then you can use a strobe light to capture "still" images.
If you need to have colored surrounding discs of multiple colors, then you'll need to adapt the algorithm. Either have color segmentation, like my tutorials in my File Exchange show you, or convert to HSV color space and look for high saturation values, which indicate a vividly colored region.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Noch keine Tags eingegeben.

Gefragt:

am 25 Mär. 2016

Bearbeitet:

am 6 Apr. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by