Droplet Dynamic Dimension determination image processing

1 次查看(过去 30 天)
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-14
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 个评论
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 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by