How to get distance between two points

6 visualizaciones (últimos 30 días)
Seunghyuk Lee
Seunghyuk Lee el 11 de Jun. de 2020
Comentada: Seunghyuk Lee el 12 de Jun. de 2020
Here is my image which i have done image processing using sobel method after the refrigerant visualization experiment.
i have filmed th flow of the refrigerant, want to get the quality of the refrigerant.
For that like to get the distance between the surface line and the bottom line.
So the question will be,
  1. how can i know the two pixel's location of the image
  2. and then how can i get the distance between those two point

Respuesta aceptada

Rafael S.T. Vieira
Rafael S.T. Vieira el 11 de Jun. de 2020
Editada: Rafael S.T. Vieira el 11 de Jun. de 2020
Hi again, Lee.
1) We can use the Hough transform for extracting lines, assuming that the pixels that we want are shown in the image (if we are not pleased with the obtained lines, we need to extract edges again from our image).
[H,T,R] = hough(cdata);%cdata is our black and white image
P = houghpeaks(H,10,'threshold',ceil(0.3*max(H(:)))); % 10 strongest peaks
lines = houghlines(cdata,T,R,P,'FillGap',5,'MinLength',7); % extract lines
% draw them in the image
img=cdata*255;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
img = insertShape(img,'Line',[xy(1,1) xy(1,2) xy(2,1) xy(2,2)],'LineWidth',2,'Color','blue');
end
imshow(img);
2) For the distance between lines, in this case, we can simply take the absolute difference between the y-coordinates (assuming that we know the m and n indexes for them):
dist = abs(lines(m).point1(2)-lines(n).point1(2));
If we want this distance to be in cm, then we need to measure the size of our tube (or desired object). This will provide us with the pixel density of our image: the ratio between pixels and its real size.
  1 comentario
Seunghyuk Lee
Seunghyuk Lee el 12 de Jun. de 2020
Really appreciate with your help, Rafael
it was helpful to use your code and suceesfuly found out the boundary line which i need it.
Also could found out the fixel location using impixelinfo function (actually the distance is only needed the y-cocordinates difference so could get the distance with the simple caculation)
But the problem was that i cant just pick one by one all by myself.
Will be there any more efficient way to get those at least 10 pixel ratio to know the quality?
(will be there any code to know the boundary line by recognizing those blu line)

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by