(UPDATED) Need to find area of an image at half length
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sai Ongole
el 8 de Jul. de 2019
Editada: KALYAN ACHARJYA
el 14 de Jul. de 2019
I have a binary image of a fuel spray. My goal is to find the cone angle of the spray. One of the research paper tells me to find the area of the spray at half length and use a formula from there. I'm struck at finding area area at half length of the spray.
The code below shows what I tried. I've also tried other methods such as trimming out all the non zero elements and just calculating the angle from the end of the spray. Since that is giving me an inaccurate answer, I'm here looking for help.
img_subt_binary= imbinarize(img_subt);
BW2= BiggestImageOnly(img_subt_binary);% Show the biggest image of the picture
figure(2),imshow(BW2),
title('Filtered Binary Image')
[pixelCount, grayLevels] = imhist(BW2);
% figure(3) % bar(grayLevels, pixelCount);
[the_length,the_width]=size(BW2)
%% Spray Angle
half_length=the_length/2;
for j=1:half_length
j=j+1;
[LL(j),WW(j)]= size(BW2);
final_width=max(WW);
end
angle= atan(final_width/half_length)
I'm expecting the angle to be around 20 degrees
0 comentarios
Respuesta aceptada
Image Analyst
el 13 de Jul. de 2019
Why not just find the right and left half edges and fit lines through them,
col1 = zeros(1, rows);
col2 = zeros(1, columns);
for row = 1 : rows
c = find(mask(row, :), 1, 'first');
if ~isempty(c)
col1(row) = c;
end
col2(row) = find(mask(row, :), 1, 'last');
end
col1(col1~=0) = []; % Remove where there were no white pixels.
col2(col2~=0) = []; % Remove where there were no white pixels.
x = 1 : length(col1);
leftCoeffs = polyfit(x, col1, 1);
rightCoeffs = polyfit(x, col2, 1);
(adapt as needed) and then use an appropriate trigonometry formula to find the angle between the two fitted lines?
3 comentarios
Image Analyst
el 14 de Jul. de 2019
Sai, those are not database functions. They are variables. "mask" is your "img_subt_binary" or your "BW2". Rows and columns are the number of rows and columns in your binary image mask:
[rows, columns] = size(BW2);
Can you do it now?
Image Analyst
el 14 de Jul. de 2019
Sai: OK I did it for you. See the red lines outlining the cone angle in the image below.

This is a much better way than the way you originally posted since it takes ALL cross sections into account, not just one row or column.
All you need to complete is how to get the angle. You can compute the angle of the top line from the coefficients and of the bottom line from the other coefficients and then subtract them to get the delta angle. I'm sure you can do it. See attached script.
Más respuestas (1)
KALYAN ACHARJYA
el 13 de Jul. de 2019
Editada: KALYAN ACHARJYA
el 13 de Jul. de 2019
Half Length of the cone area, lets say binary image is image_bw
[rows colm]=size(image_bw);
image_bw(1:round(rows/2),:)==0;
% Area in % with respect to Total Image
area_half_cone=(sum(image_bw)/(rows*colm))*100;
Here, used calculated the lower half of the cone

4 comentarios
KALYAN ACHARJYA
el 14 de Jul. de 2019
Editada: KALYAN ACHARJYA
el 14 de Jul. de 2019
I need the area of the upper half of the cone...
image_bw(round(rows/2):end,:)==0;
Rest code is same, please do refer the answer of @ImageAnalyst too.
Ver también
Categorías
Más información sobre Computer Vision with Simulink en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!