Find end to end distance of fusing droplets

2 views (last 30 days)
Archishman Ghosh
Archishman Ghosh on 28 Apr 2020
Answered: Archishman Ghosh on 28 Apr 2020
I have a series of images of fusing droplets. I would like to get the horizontal end to end distance of the fusing droplets. This distance shortens over time as the two droplets fuse.
I have tried the regionprops boundingbox approach but it doesn't seem to work. Several tiny rectangles form around the droplets. Perhaps the image needs to be cleaned up after turning into binary.
Does anyone have an alternative approach to this?
function [] = boundingbox(file,level)
image=imread(file);
figure
BW=im2bw(image,level);
BW = ~BW;
imshow(BW)
st = regionprops(BW, 'BoundingBox' );
for k = 1 : length(st)
thisBB = st(k).BoundingBox;
rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],...
'EdgeColor','r','LineWidth',2 )
end
end

Answers (1)

Archishman Ghosh
Archishman Ghosh on 28 Apr 2020
This works only for images with very high contrast. So the code is limited to the contrast. Anyway to enhance contrast without introducing noise in an image?
function D = boundingbox(file,level)
image=imread(file);
figure
BW=im2bw(image,level);
%BW = ~BW;
imshow(BW)
BBs = [];
measurements = regionprops(BW, 'BoundingBox', 'Area');
for k = 1 : length(measurements)
thisBB = measurements(k).BoundingBox;
%rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],...
%'EdgeColor','r','LineWidth',2 )
BBs = [BBs;thisBB];
end
areas=cat(1,measurements.Area);
[sortedAreas, sortingIndexes] = sort(areas, 'descend');
fusionindex = sortingIndexes(2);
rectangle('Position', [BBs(fusionindex,1),BBs(fusionindex,2),BBs(fusionindex,3),BBs(fusionindex,4)],...
'EdgeColor','r','LineWidth',2 )
D = BBs(fusionindex,3);
end

Community Treasure Hunt

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

Start Hunting!