How to find breakup length?
Show older comments
I want to find the distances AB and CD. That would give me the breakup length for the liquid sheet.
This is the code that I have used till now:
a = imread('GrayImage.jpg');
b = (474:512);
for i = 1:1:474
for j = 1:1:512
if a(i,j) < 200
b(i,j) = 0;
else
b(i,j) = 255;
end
end
end
c = imbinarize(b);
numberToExtract = 1;
binaryImage = imfill(imcomplement(c), 'holes');
[labeledImage, numberOfBlobs] = bwlabel(binaryImage);
blobMeasurements = regionprops(labeledImage, 'area');
allAreas = [blobMeasurements.Area];
[sortedAreas, sortIndexes] = sort(allAreas, 'descend');
biggestBlob = ismember(labeledImage, sortIndexes(1:numberToExtract));
binaryImage = biggestBlob > 0;
I am finding it difficult to find these distances next. I know that we can find the length of boundary using regionprops, but how can I limit that between those points. Doing it manually is not an option, as i have more than 20000 images to go through.
i am also not sure whether the approach that i have taken is right of wrong.
5 Comments
KALYAN ACHARJYA
on 26 Apr 2019
Yes, you have BL_binary iamge, as attched. Now can you elaborate what exactly you want on that image (I am talking binary image)
You can use paints or image tool to clarify the issue, break up means?
Edin Michael
on 26 Apr 2019
Edin Michael
on 26 Apr 2019
Akhir Shaik
on 21 Jan 2020
same problem i need to measure breakup length for 20000 images, can u please clarify to me, i'm new to matlab
Image Analyst
on 22 Jan 2020
Accepted Answer
More Answers (1)
Image Analyst
on 27 Apr 2019
0 votes
Edin:
Try the attached code.

What I've done is to find a threshold that seems to work and threshold the image, then take the largest blob and fill the holes, then scan from left to right and find the lowest level where there is white, then take the mean of those bottom lines. This seems to work fairly well for this image, which has a flat bottom.
If your images usually have more of a fan-shape instead of a flat bottom, then we might want to find the edges and extrapolate back to the vertex point (which is above the top of the image and seems to be missing), then find the average radial distance instead of the average horizontal level. Not too hard but let me know if you need to do that and can't figure it out.
And of course there is the potential of bizarre shapes, like a lower case g shape or upper case I shapes. For cases like that you'd have to define what you mean by breakup length.
7 Comments
Edin Michael
on 30 Apr 2019
Image Analyst
on 1 May 2019
Why do you think it's only the very outermost parts of the stream that matters, and how far most of the bulk of the spray goes does not matter at all?
Akhir Shaik
on 17 Feb 2020
i have used your code for processing 20000 images, but i am getting only one image value. i don't know how to approach.
%% Get the name of the image the user wants to use.
myFolder = 'E:\IMAGES\100k\flip';
if exist(myFolder, 'dir') ~= 7
Message = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(Message));
return;
end
filePattern = fullfile(myFolder, '*.jpg');
jpegFiles = dir(filePattern);
for k = 1:length(jpegFiles)
baseFileName = jpegFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf('Now reading %s\n', fullFileName);
end
%% read image
grayImage = imread(fullFileName);
% Get the dimensions of the image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
grayImage = rgb2gray(grayImage);
end
% Do a histogram
% histogram(grayImage);
% Interactively/visually threshold using code at
% https://www.mathworks.com/matlabcentral/fileexchange/29372-thresholding-an-image
% [lowThreshold, highThreshold, lastThresholdedBand] = threshold(235, 255, grayImage);
highThreshold = 150;
binaryImage = grayImage <= highThreshold;
% Clean it up.
% Extract largest blob.
binaryImage = bwareafilt(binaryImage, 1);
% Fill holes.
binaryImage = imfill(binaryImage, 'holes');
% Method 1: determine the level (line, row) that is the average lowest level:
bottomLine = zeros(rows, 1);
for col = 1 : columns
thisColumn = binaryImage(:, col);
lastLine = find(thisColumn, 1, 'last');
if ~isempty(lastLine)
bottomLine(col) = lastLine;
end
end
meanbottomLine = mean(bottomLine(bottomLine>0));
[row, col] = find(isnan(meanbottomLine(:,2)));
save bkl_.dat meanbottomLine -ascii
Image Analyst
on 18 Feb 2020
That's because there's essentially no code in the loop:
for k = 1:length(jpegFiles)
baseFileName = jpegFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf('Now reading %s\n', fullFileName);
end
You're just getting and overwriting file names - that's all. No image processing at all, except for the very last filename because that processing code comes AFTER the loop. You need to put the processing code that you currently have AFTER that loop INTO that loop.
Akhir Shaik
on 18 Feb 2020
is this code works for loop...? if not can u please help me.
for i=1:l
if (i<10)
picA=imread(['0000' num2str(i) '.jpg']);
elseif (i<100)
picA=imread(['000' num2str(i) '.jpg']);
elseif (i<1000)
picA=imread(['00' num2str(i) '.jpg']);
elseif (i<10000)
picA=imread(['0' num2str(i) '.jpg']);
else
picA=imread([num2str(i) '.jpg']);
end
piccell{i}=picA;
end
Image Analyst
on 18 Feb 2020
Try this:
for i=1:l
fileName = sprintf('%5.5d.jpg', i)
piccell{i} = imread(fileName);
end
If you have a lot of images, you may run out of memory. Why do you need to store all the images in advance in a cell array anyway? I never do that. Why are you doing it? Just process them immediately after you read them in. No reason to store them in a cell array as far as I can see.
Akhir Shaik
on 19 Feb 2020
thank you sir, but it is getting overridden and taking the last image and solving only one image. i need to process more images
i need to save the file in .dat can pls help me
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

