How to get distance between two points
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Rafael S.T. Vieira
2020년 6월 11일
편집: Rafael S.T. Vieira
2020년 6월 11일
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!