To find Droplet size distribution, number density and unwanted background spots
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi, I have high speed captured images of multiple droplets as I attached in the file. I want to find out the droplet size distribution and its's number density for each frames and I want to remove unwanted background spots present in each frame (you can see in the image). If someone can help me in it then I would be greatful to him, as I am new in the image processing.
댓글 수: 0
채택된 답변
Shubham
2024년 5월 21일
편집: Shubham
2024년 5월 21일
Hey Manojkumar,
It seems that you are trying to find the droplet size distribution and density of the droplets per frame. Before performing any such computations, you need to segment the image such that the droplets are clearly distinguishable from the background.
You can begin with loading the image using "imread" function then convert the image to grayscale using "rgb2gray" function. Convert the grayscale image to binary (black and white) so that the droplets are clearly distinguishable from the background using the "imbinarize" function: https://www.mathworks.com/help/images/ref/imbinarize.html
You can play around with these functions to get the desired result. For example:
img = imread('drops.jpeg');
img = rgb2gray(img); %convert from RGB to grayscale
img2 = imcomplement(img); %complement the image (black background and white drops)
figure(1);
binaryImg = imbinarize(img,0.1); % binarize using a threshold
binaryImg2 = imcomplement(binaryImg);
imshowpair(img2,binaryImg2,'montage'); %show initial and final
You can improve upon the thresholding by using positional arguments in the "imbinarize" function, for example:
binaryImg = imbinarize(img, 'adaptive', 'ForegroundPolarity','dark','Sensitivity',0.1);
binaryImg2 = imcomplement(binaryImg);
figure(4);
imshowpair(img2,binaryImg2,'montage');
You can use the color thresholder app for thresholding: https://www.mathworks.com/help/images/ref/colorthresholder-app.html
You can leverage various contrast enhancement techniques as mentioned here: https://www.mathworks.com/help/images/contrast-enhancement-techniques.html
You could also detect circles in your image using "imfindcircles" function. I have used the image segmenter app in the Image processing toolbox to find circles: https://www.mathworks.com/support/search.html/videos/image-segmentation-app-1504291389509.html
I have generated the following function:
function [BW,maskedImage] = segmentImage(RGB)
%segmentImage Segment image using auto-generated code from Image Segmenter app
% [BW,MASKEDIMAGE] = segmentImage(RGB) segments image RGB using
% auto-generated code from the Image Segmenter app. The final segmentation
% is returned in BW, and a masked image is returned in MASKEDIMAGE.
% Auto-generated by imageSegmenter app on 21-May-2024
%----------------------------------------------------
% Find circles
[centers,radii,~] = imfindcircles(RGB,[1 75],'ObjectPolarity','dark','Sensitivity',0.98);
max_num_circles = Inf;
if max_num_circles < length(radii)
centers = centers(1:max_num_circles,:);
radii = radii(1:max_num_circles);
end
BW = circles2mask(centers,radii,size(RGB,1:2));
% Create masked image.
maskedImage = RGB;
maskedImage(repmat(~BW,[1 1 3])) = 0;
end
The above function produced an image similar to binaryimage using adaptive thresholding as shown.
Please refer to the following MATLAB Answers which could be relevant to your query: https://www.mathworks.com/matlabcentral/answers/600700-detecting-droplets-in-an-image
Once you have segmented the image, you can use the "regionprops" function to derive all the statistics. For example:
regionprops('table', maskedImage, 'Area', 'Centroid');
The above function call produced the following output:
Area Centroid
____ __________________________
336 816.12 525.04 2
372 858.41 567.7 2
318 842.12 578.87 2
330 830.43 589.3 2
222 821.78 549.97 2
: :
15 507 471 2
12 506 400.25 2
30 526.4 420.4 2
36 529.58 292.92 2
102 463.82 414.97 2
Using the above statistics you can easily derive the size distribution and number density for each frames.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!