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!