image corner and objects relationship

I have 2 object and they are different color.Object1's corner and object2's corner should hold the different matrix. How could i do that?

답변 (3개)

Image Analyst
Image Analyst 2017년 4월 30일
편집: Image Analyst 2017년 4월 30일

0 개 추천

Get the centroids
[rows, columns] = size(binaryImage);
[labeledImage, numBlobs] = bwlabel(binaryImage);
props = regionprops(labeledImage, 'Centroid')
Then go through each centroid finding out which of the 4 corners of the image is closest to your blob. Untested code:
for k = 1 : numBlobs
thisX = props(k).Centroid(1); % x value.
thisY = props(k).Centroid(2); % y value.
% Find distance to lower left corner
distanceLL = sqrt((thisX-1)^2 + (thisY-rows)^2);
% Find distance to lower right corner
distanceLR = sqrt((thisX-columns)^2 + (thisY-rows)^2);
% Find distance to upper left corner
distanceUL = sqrt((thisX-1)^2 + (thisY-1)^2);
% Find distance to upper right corner
distanceUR = sqrt((thisX-columns)^2 + (thisY-1)^2);
if distanceLL < distanceUL && distanceLL < distanceUR && distanceLL < distanceLR
% It's closest to the lower left corner.
else if..............etc.
end
end

댓글 수: 1

Image Analyst
Image Analyst 2017년 5월 1일
Note: was an answer to the original question, which has since been replaced.

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

CIHAT ZOROGLU
CIHAT ZOROGLU 2017년 4월 30일

0 개 추천

Thanks for your help but What i want to find this, for example we have 3 objects in image.Object1's corner points hold different array, object 2's corner points hold different array etc..

댓글 수: 3

Image Analyst
Image Analyst 2017년 4월 30일
You've accepted your own answer so I assume you figured it out.
Attaching a figure, screenshot, or diagram would have let me attempt the correct code instead of all that wasted code I wrote. http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
CIHAT ZOROGLU
CIHAT ZOROGLU 2017년 4월 30일
No, i accept mistakenly
Image Analyst
Image Analyst 2017년 4월 30일
I still don't know what to say. Give us something else to go on. Did you read the link I gave you?

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

CIHAT ZOROGLU
CIHAT ZOROGLU 2017년 5월 1일
편집: Image Analyst 2017년 5월 1일

0 개 추천

Here. I have 2 object and they are different color. Object1's corner and object2's corner should hold the different matrix. How could i do that?

카테고리

도움말 센터File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

질문:

2017년 4월 30일

댓글:

2017년 5월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by