correct quadrant and angle when not using roipoly
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi I'm trying to make 2 objects in a picture the points of interest however, the problem I'm facing is that I can't get the angle of the point of interest. the simpler solution would be to do it with roipoly but then i wont understand the how...
The picture contains the 2 lego platforms I intend to mark as points of interests but when selecting the right one I get a square with the background table. So in the code I need to account for the angle, I'm trying to make all my codes more general purpouse hens the switch case i know i should implement it in a loop for more objects than two but that comes later at the moment i just need to solve this hurdle.
cam = webcam;
img_piece = snapshot(cam);
figure;imshow(img_piece);
hold on;
roi1 = drawpolygon;
mask1 = createMask(roi1);
draw(roi1);
mask2 = createMask(roi1);
mask = mask1 + mask2;
pause
maskedImg = img_piece;
for i = 1:size(img_piece,1)
for j = 1:size(img_piece,2)
if ~mask(i,j)
maskedImg(i,j,:) = [0 0 0];
end
end
end
figure;imshow(maskedImg);
%% EDIT: the code now contains the correct answer but for multiple uses you need to make it your own
댓글 수: 0
채택된 답변
Image Analyst
2021년 1월 2일
편집: Image Analyst
2021년 1월 2일
You need to use roipolyold() or drawpolygon() instead of all that with ginput(), etc.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!