How to get distance between two points
3 views (last 30 days)
Seunghyuk Lee on 11 Jun 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,
- how can i know the two pixel's location of the image
- and then how can i get the distance between those two point
Rafael S.T. Vieira on 11 Jun 2020
Edited: Rafael S.T. Vieira on 11 Jun 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
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');
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.