How to eliminate unwanted objects from droplet image to ease droplet identification/sizing and strange imcrop behaviour

4 vues (au cours des 30 derniers jours)
The above picture is a shadowgraph image of some water droplets falling in a pilot column dryer with unwanted dust/dirt from the lens. I've some pre existing code which sizes droplets. Unfortunately, I was not intelligent enough to find something to wipe down the camera lens with and as such, for the aqcuisition of all images, there are specks of dust/dirt which were on the lens.Please could someone suggest a method for getting rid of these , given that they are the same in every image, to ease the droplet IDing/sizing?
The alternative is to crop the images as fortunately this eliminates most of the specs. I do crop them anyway, however, using
imcrop(I,rect)
is giving me problems as for some reason it appears to not obey when i try to make it narrower. The image is 2048x2048 pixels, and ideally, a good crop rectangle would be
imcrop(I,[1100 0 1300 2048])
but for some reason, it wont go as narrow as i want it to in this region of the image, instead leaving a rectangle of width approx 900 pixels? im very confused by this as when i test the crop on the left most and right most regions of the image, i am able to obtain the desired, thin sliver of the image e.g
imcrop(I,[10 0 20 2048]) %or
imcrop(I,[2028 0 2038 2048])
both deliver exactly the cropped image you would expect.
In summary, if there are any suggestiosn to remove those specks or to fix my imcrop, I would be most grateful.
Thanks in advance

Réponse acceptée

Image Analyst
Image Analyst le 12 Juin 2021
First you need to flatten the background. One of the best ways is to take a blank shot with no sample in there to get an image of just the light pattern. Then convert that to a percentage image where each pixel is a percentage of the max value (which is usually at the center). Then take a test picture and divide the test picture by the percentage image.
If you can't take a blank shot you can try to flatten the image using CLAHE using adapthisteq(). Or you can fit a polynomial like in my attached demo.
Once you have a flattened image you can try imbinarize() with either a global threshold (default) or the 'adaptive' option. Now you'll have some blobs. You can filter based on the known size range with bwareafilt(). You can also filter based on circularity to throw out non-circular blobs
mask = imbinarize(mask);
mask = bwareafilt(mask, [lowArea, highArea]); % filter based on area (number of pixels in the blob).
props = regionprops(mask, 'Area', 'Perimeter')
allAreas = [props.Area];
allPerimeters = [props.Perimeter];
circularities = allPerimeters ./ (4 * pi * allAreas); % = 1 for a perfect circle
roundBlobsIndexes = circularities < 3; % or whatever you want.
[labeledImage, numBlobs] = bwlabel(mask);
% Extract good round blobs
mask = ismember(labeledImage, roundBlobsIndexes);
Replace variable names with whatever you're using of course.
  2 commentaires
Harry Morgan
Harry Morgan le 12 Juin 2021
Hi Image Analyst,
Thanks very much. I am unable to obtain a blank shot currently, but i will give the alternatives a go.
Aside from this, have yoy any clue as to why imcrop seems to be behaving weirdly for me?
Thanks once again
Image Analyst
Image Analyst le 12 Juin 2021
I don't know. Just use indexing
croppedImage = originalImage(:, 1100 : 2400, :);

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by