MATLAB Answers

0

how to measure angle and flame speed from Picture ..

Asked by Ayuob Alwahaibi on 9 Oct 2019
Latest activity Edited by Tushal Desai on 11 Oct 2019
i would like to measure:
1) the angle (Θ)of the tip of the flame from the picture.
2) the flame speed from the following equation:
SL= V * sin(Θ) , knowing that V= 130 m/s, and the Θ is what im looking for in number (1)
i need help ASAP, please help!!!!!!

  1 Comment

What have you tried? What about imline?

Sign in to comment.

3 Answers

Answer by Stephan
on 9 Oct 2019
Edited by Stephan
on 9 Oct 2019
 Accepted Answer

I used this documentation example to build this code:
% find lines
I = imread("5t.JPG");
I1 = rgb2gray(I);
I1 = imbinarize(I1,'adaptive','ForegroundPolarity','bright');
BW = edge(I1,'Sobel');
[H,theta,rho] = hough(BW);
P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));
lines = houghlines(BW,theta,rho,P,'FillGap',5,'MinLength',100);
% Angle from lines objects
angle_between_lines = abs(lines(1).theta) + abs(lines(2).theta);
fprintf('Angle between lines from Lines objects: %.2f°\n',angle_between_lines);
% calculate angle by the endpoints of the lines for more accurate results
angle_calc = atand((abs(lines(1).point1(1) - lines(1).point2(1))) /...
(abs(lines(1).point1(2) - lines(1).point2(2)))) +...
atand((abs(lines(2).point1(1) - lines(2).point2(1))) /...
(abs(lines(2).point1(2) - lines(2).point2(2))));
fprintf('Angle between lines calculated from endpoints: %.2f°',angle_calc);
% show results
figure(1)
imshow(I)
hold on
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
end
hold off
ends in:
and result:
Angle between lines from Lines objects: 67.00°
Angle between lines calculated from endpoints: 67.14°

  0 Comments

Sign in to comment.


Answer by Ayuob Alwahaibi on 9 Oct 2019
Edited by Tushal Desai on 11 Oct 2019

Thanks Stephan, but the code works for only the picture i attached. i tried the code with other picture, but i keep getting error "Error in SL2 (line 10)
angle_between_lines = abs(lines(1).theta) + abs(lines(2).theta);"
here are some other pictures, can you please modify the code in a way that can work with any of the pictures below: ltr

  0 Comments

Sign in to comment.


Answer by Stephan
on 10 Oct 2019

Usually i would not open a new answer - but this question is weird, because i can not comment it for some technical reason. However this improved version of the code works for al the pictures you attached:
% find lines
I = imread("5t.JPG");
I1 = I(:,:,3);
treshold = 0.82*max(max(I1));
I1(I1<treshold) = 0;
I1 = imbinarize(I1,'adaptive','ForegroundPolarity','bright');
[H,theta,rho] = hough(I1);
NHoodsize = (2*round(size(H)/10,0))+1;
P = houghpeaks(H,2,'threshold',ceil(0.5*max(H(:))),'NHoodSize',NHoodsize);
lines = houghlines(I1,theta,rho,P,'FillGap',5,'MinLength',10);
% Angle from lines objects
angle_between_lines = abs(lines(1).theta) + abs(lines(2).theta);
fprintf('Angle between lines from Lines objects: %.2f°\n',angle_between_lines);
% calculate angle by the endpoints of the lines for more accurate results
angle_calc = atand((abs(lines(1).point1(1) - lines(1).point2(1))) /...
(abs(lines(1).point1(2) - lines(1).point2(2)))) +...
atand((abs(lines(2).point1(1) - lines(2).point2(1))) /...
(abs(lines(2).point1(2) - lines(2).point2(2))));
fprintf('Angle between lines calculated from endpoints: %.2f°',angle_calc);
% show results
figure(1)
imshow(I)
hold on
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
end
hold off

  0 Comments

Sign in to comment.