How to get distance between two points
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Seunghyuk Lee
le 11 Juin 2020
Commenté : Seunghyuk Lee
le 12 Juin 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
0 commentaires
Réponse acceptée
Rafael S.T. Vieira
le 11 Juin 2020
Modifié(e) : Rafael S.T. Vieira
le 11 Juin 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.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!