Find the actual distances in an image.

조회 수: 3(최근 30일)
Chathu
Chathu 2016년 4월 15일
댓글: Chathu 2016년 4월 30일
I want to find the minimum x(1) value which touches the image,A. Then maximum x(2) value which touches the image,A.(ps:image is attached). I made the axis ON. SO i want to let the program identify the x(min), x(max),y(min) and y(max), next draw straight lines(as shown in the image) along above said points(eg:x(1),x(2),etc) and then perform the spatial calibration (note; image is not symmetric). Can anyone give me a hint how to resolve this issue.
  댓글 수: 2
Chathu
Chathu 2016년 4월 15일
it is an image. Let me add it here now. Sorry for the confusion.

댓글을 달려면 로그인하십시오.

채택된 답변

Mohammad Abouali
Mohammad Abouali 2016년 4월 15일
Similar approach to this should work:
I=imread('P3290337.JPG');
I=padarray(I,[1 1 0],0);
thresh = 15;
mask = ~(I(:,:,1) < thresh & I(:,:,2) < thresh & I(:,:,1) < thresh);
xProj = any(mask);
xMin = find(xProj,1,'first')-0.5;
xMax = find(xProj,1,'last');
yProj = any(mask,2);
yMin = find(yProj,1,'first');
yMax = find(yProj,1,'last');
imshow(I);
hold on
plot([xMin xMin],ylim,'r','LineWidth',2)
plot([xMax xMax],ylim,'r','LineWidth',2)
plot(xlim,[yMin yMin],'r','LineWidth',2)
plot(xlim,[yMax yMax],'r','LineWidth',2)
  댓글 수: 4
Chathu
Chathu 2016년 4월 30일
@ Mohammad, i saw your response just now. Your approach is perfect for my purpose, as it is short distance.
Thank you so much for your response. Highly appreciate it:)

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Image Analyst
Image Analyst 2016년 4월 16일
See my spatial calibration demo.
  댓글 수: 1
Chathu
Chathu 2016년 4월 16일
Thank you so much Image Analyst. Highly appreciated.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by