How to find breakup length?

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 Commenti

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
Edin Michael il 26 Apr 2019
Breakup is the process of liquid sheet breaking into droplets.
I would like to have the cordinates of the pixel where the value 1 occurs for the first time and also those of the pixel where 1 occurs for the last time in the first row.
I also want the coordinates of the pixels having the value 1 which are closest to both the left and right boundaries.
Edin Michael
Edin Michael il 26 Apr 2019
is it possible to find the length between two pints on the boundary along the boundary?
Akhir Shaik
Akhir Shaik il 21 Gen 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
Image Analyst il 22 Gen 2020
Use code from the FAQ, combined with the solution from my Answer below.

Accedi per commentare.

 Risposta accettata

Guillaume
Guillaume il 26 Apr 2019
I assume you know the scale of your image otherwise the whole exercise is a bit pointless...
The nozzle orifice is not visible in your image. Normally, the breakup length is measured from the orifice, so here you have an unknown constant to add to whatever you measure.
Since your spray is vertical, measuring the breakup length is easy, it's just the vertical position of the lowest true pixel of your binary image, so:
[pixrow, ~] = find(binaryImage);
breakupkength_pixel = max(pixrow);

12 Commenti

Edin Michael
Edin Michael il 26 Apr 2019
Thank you.
I have removed the nozzle from the image and what you see is the nozzle exit at the top.
I would like to find the pixel coordinates of the nearest and the farthest pixel (from the left border) with value 1.
Is there anything that can be done?
The nearest and farthest pixels from the left border of the image are simply the leftmost and rightmost columns of your true pixels, so once again:
[~, pixcol] = find(binaryImage);
[leftmost, rightmost] = bounds(pixcol); %or use min max if <R2017a
Edin Michael
Edin Michael il 26 Apr 2019
Thanks a lot.
Edin Michael
Edin Michael il 26 Apr 2019
Is it possible to find the distance between two points on a given boundary along the boundary itself?
darova
darova il 26 Apr 2019
I'd loop every column of an image from leftmost to rightmost and find first entry
img.png
Imagine that rows and columns of pixels are coordinates:
img.png
Edin Michael
Edin Michael il 29 Apr 2019
Modificato: Edin Michael il 29 Apr 2019
thanks a lot for your help.
Image Analyst
Image Analyst il 29 Apr 2019
Why do you want " distance between two points on a given boundary along the boundary itself"? If you really want that, you can use bwboundaries() and pdist2(). By the way, did you see my solution below?
darova
darova il 29 Apr 2019
Image Analyst, how can i compute length of a red curve using ? (i have x and y vectors)
img.png
Image Analyst
Image Analyst il 29 Apr 2019
I don't recommend that. You didn't give any logical reason why this is needed after I asked, so I don't recommend it.
I think my solution is better than just looking at the two outer lines. Mine looks at ALL endpoints so I think that is better.
Edin Michael
Edin Michael il 30 Apr 2019
Image Analyst,
The reason I needed the distance along the boundary itself is that, i want to know what is the length of the liquid sheet along the boundary before it breaks into ligaments and droplets. This is purely for academic purposes.
Guillaume
Guillaume il 30 Apr 2019
You could get the length of your edges by getting the pixels with bwboundary and then calculating the distance between contiguous pixels (simple pythagorean rule) once you've identified the start and end pixel. However, there's a risk that accumulation error may make the result fairly innacurate
The way I normally do it instead is to fit a straight line through these edge pixels and calculate the line length between the nozzle orifice and the tip of the spray.
Edin Michael
Edin Michael il 30 Apr 2019
Guillaume,
Thank you

Accedi per commentare.

Più risposte (1)

Image Analyst
Image Analyst il 27 Apr 2019

0 voti

Edin:
Try the attached code.
0000 Screenshot.png
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 Commenti

Edin Michael
Edin Michael il 30 Apr 2019
I tried the code, but for some of the images, the breakuplength obtained is having a higher value than the actual breakuplength.
I am guessing that it might be because there is an overlap of the images or also because of the reason that the front portion of the conical sheet is outside the plane of focus.
So, what I am currently doing is to focus on the left and right edges as they are both in focus and at there is no overlapping issue there.
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?
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
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.
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
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
Akhir Shaik il 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

Accedi per commentare.

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by