Droplet Dynamic Dimension determination image processing

Hello, I have a code there is a droplet separating from a injector and it flows and change shapes. When you run the code it asks you to crop the image around the area which the droplet is moving and then the rest of the code executes. I used to use a circle for recognition of the droplet, now since the droplet is changing shape, my code is not working and I want to count pixels of my pixel! can someone help me with this? The part that says CODE BELOW in a comment mode I want to add my image. I am only attaching one image of 175 images. I just need a hint how to do such thing except from circling the droplet which is from some image forward is not circular anymore.
analysis part.
clear
clc
close all
AutoThreshold = true;
CropImage = true;
Shadowgraphy = true; %// For OH chemiluminescence = false
ExportTracking = false;
StartTime = 50; %// Start time of video data in ms
%//-------------------------------------------------------------------------------------------------------------------------------------//
folder = pwd;
if AutoThreshold == false
prompt = {'Enter Threshold value (0-1):'};
boxTitle = 'Threshold';
definput = {'Shadowgraphy: 0.2 / OH chemiluminecsence: 0.5'};
threshold = str2double(inputdlg(prompt,boxTitle,[1 50],definput));
end
imageFiles = [dir([folder '\*.jpg']);dir([folder '\*.png'])];
numFiles = length(imageFiles);
data(1:numFiles,1:3) = NaN;
for trackingNo = 0:9 %// check if old tracking exist and make new folder
if trackingNo == 0 && exist([folder '\Tracking'], 'dir')
exportPath = ['\Tracking_' num2str(trackingNo+1)];
elseif trackingNo == 0 && ~exist([folder 'Tracking'], 'dir')
exportPath = ['\Tracking_' num2str(trackingNo+1)];
end
if trackingNo > 0 && exist([folder '\Tracking_' num2str(trackingNo)], 'dir')
exportPath = ['\Tracking_' num2str(trackingNo+1)];
end
end
mkdir(folder, exportPath);
for x = 1:numFiles
%// Calculate actual time
if Shadowgraphy == true
time = (x-1)/2000*1000+StartTime;
else
time = (x-1)/1600*1000+StartTime;
end
%// Load image & select cropping position
A = imread([folder '\' imageFiles(x).name]);
if CropImage == true && x == 1
cropFigure = figure('Name','Crop Image: Draw a rectangle','NumberTitle','off','units','normalized','outerposition',[0 0 1 1]);
imshow(A);
crop = imrect;
addNewPositionCallback(crop,@(p) title(mat2str(p,3)));
fcn = makeConstrainToRectFcn('imrect',get(gca,'XLim'),get(gca,'YLim'));
setPositionConstraintFcn(crop,fcn);
position = wait(crop);
cropPosition = getPosition(crop);
close(cropFigure);
end
%// Crop image
if CropImage == true
cropPosition = round(cropPosition);
A = imcrop(A,cropPosition);
end
%// Treshold image
if AutoThreshold == true
if Shadowgraphy == true
threshold = isodata(A);
else
threshold = graythresh(A);
end
end
%//---------------CODE BELOW-------------------------------------------------------
A1 = A;
minGL = min(A1(:));
maxGL = max(A1(:));
meanGL = mean(A1(:));
% [X, Y] = param_detect02(175,A1,150,maxGL,0,0,0,0.1);
%
% A = im2bw(A,threshold);
% A = bwareafilt(A, 1);
% BW1 = double(im2bw(A,0.15));
% [accum, circen, cirrad] = CircularHough_Grd(A1, [15 2000]);
% BW1 = imfill(A1, 'holes');
% % labeledImage = bwlabel(A);
% A1 = edge(A1,'sobel',threshold);
%// Save data
data(x,1) = time;
data(x,2) = x; %radius of circle
data(x,3) = 0; %x position of circle
data(x,4) = 0; %y position of circle
%//----------------------------------------------------------------CODE ABOVE------------------------------------------------------
%// Display every 10th image
selector = 1:10:401;
if ismember(x,selector)
subplot(4,5,ceil(x/10))
imshow( A1);
hold on
% subplot(circen(1,1), circen(1,2), cirrad, 32, 'g');
%title(['Image ' num2str(x)],'FontSize',16);
title(['t = ' num2str(time) ' ms'],'FontSize',16);
end
if x == numFiles
export_fig([folder exportPath '\Overview.png']);
end
%// Export images with tracking
if ExportTracking == true
figure('Units','normalized','Position',[0 0 1 1])
imshow(A1);
hold on
title(['Image ' num2str(x)],'FontSize',16);
export_fig([folder exportPath '\Tracking_' num2str(x) '.png']);
close;
end
%// Display progress in %
Progress = round(x/numFiles*100);
end
%// Show & export regression plot
% figure('Name','Diameter Regression Plot','NumberTitle','off','units','normalized','outerposition',[0 0 1 1]);
% plot(data(:,1),data(:,2));
%
% title('Diameter Regression');
% xlabel('Time [ms]');
% ylabel('Diameter [px]');
% export_fig([folder exportPath '\Diameter-Regression.png']);
%// Clear all NaN rows & export data
data = data(all(~isnan(data),2),:);
csvwrite([folder exportPath '\Diameter-Regression.txt'], data);

7 件のコメント

darova
darova 2020 年 4 月 13 日
Can you identificate the part you want to calculate the pixels?
Sepehr Ariaei
Sepehr Ariaei 2020 年 4 月 13 日
The second part (number 2). I would like to see what is the number of pixels or the area of number 2
darova
darova 2020 年 4 月 14 日
Can you upload a few more images for my experiments?
Sepehr Ariaei
Sepehr Ariaei 2020 年 4 月 14 日
Yes sure, Please find the link in Google Drive to the directory of the whole images.
Sepehr Ariaei
Sepehr Ariaei 2020 年 4 月 14 日
And thank you for helping! I cannot appreciate enough
darova
darova 2020 年 4 月 14 日
Can't success. Don't have permission. Other ideas?
Sepehr Ariaei
Sepehr Ariaei 2020 年 4 月 14 日
I gave you access. You are Mykola Prykhodko right?

サインインしてコメントする。

 採用された回答

darova
darova 2020 年 4 月 14 日

0 投票

Here is an idea:
  • i cropped region of interest and reduced/dilated to separate each area
  • i expanded each area separately in for loop
  • then i want to ask user to pick area of interest
  • choose correct threshold for your image
graythresh-0.3 graythresh-0.0
I1 = im2bw(I,graythresh(I)-0.1); % binarize

6 件のコメント

Sepehr Ariaei
Sepehr Ariaei 2020 年 4 月 16 日
Thank you very much for helping me on this. There are some drawbacks. firstly it does not detect the last images where the droplet is a little fading and also at some parts when there is a overlap between the droplet and injector, it will count the pixels of the injector too. Moreover, can you give me a little idea of how can this selection of the part to count pixels can become more autonomous and me not picking the part?
darova
darova 2020 年 4 月 16 日
Ok. i made some improvements. Here are some notes
  • Ideally after processing there are only two blobs: water and glass. I noticed that glass is always remains at the same place. So correctly identificate waterdrop i added checking
P = [100 85]; % coordinates of glass
  • Sometimes when waterdrop is small reduce size of disk (dilation)
se1 = strel('disk',12,6); % put here 8 instead of 12
  • When waterdrop is large increase strel element to separate it from glass
se1 = strel('disk',16,6); % put here 16 instead of 12
Just put this script inside folder with images. Let me know if something is wrong
Sepehr Ariaei
Sepehr Ariaei 2020 年 4 月 27 日
編集済み: Sepehr Ariaei 2020 年 4 月 27 日
Dear Darova,
Thank you for your code it is working very good when you play around a little bit with the strel and other numbers! there is only one last problem which I promise it would be the last. I added an " if" to choose different disk size for different versions. The only problem is that when that shadow of water vapor appears after some image around 110 something forward, there is a problem. Instead of detection of the the droplet , it detects the water vapor pixels. How can I deal with that?
darova
darova 2020 年 4 月 27 日
Please show some of problems images
I assume that you tried to change threshold?
I1 = im2bw(I,0.07); % binarize
Sepehr Ariaei
Sepehr Ariaei 2020 年 4 月 27 日
編集済み: Sepehr Ariaei 2020 年 4 月 27 日
No actually I have not.
Please find the attached file
darova
darova 2020 年 4 月 27 日
this line
disp(['ERROR: ', str])
produces something like
ERROR image1
ERROR image2
...
You take all problem images to another folder and process them there
  • No actually I have not.
Then you should try

サインインしてコメントする。

その他の回答 (0 件)

製品

リリース

R2015b

質問済み:

2020 年 4 月 13 日

コメント済み:

2020 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by