plot orientations using quiver only in the mask region...
3 次查看(过去 30 天)
显示 更早的评论
[rows, cols] = size(orient);
len = 0.8*spacing;
s_orient = orient(spacing:spacing:rows-spacing, spacing:spacing:cols-spacing);
xoff = len/2*cos(s_orient);
yoff = len/2*sin(s_orient);
[x,y] = meshgrid(spacing:spacing:cols-spacing, ...
spacing:spacing:rows-spacing);
x = x-xoff;
y = y-yoff;
u = xoff*2;
v = yoff*2;
figure, imshow(I), hold on;
quiver(x,y,u,v,0,'.','linewidth',1,'color','r'); hold off;
i want to plot the quiver only in non-zero positions of "orient"...
1 个评论
采纳的回答
Image Analyst
2017-2-20
I think you'll have to go down your list of x and y and determine if the point is inside or outside the ROI using the inpolygon() function.
rowsToKeep = false(1, length(x));
for k = 1 : length(x)
if inpolygon(x(k), y(k), xSquare1, ySquare1)
rowsToKeep(k) = true;
end
if inpolygon(x(k), y(k), xSquare2, ySquare2)
rowsToKeep(k) = true;
end
if inpolygon(x(k), y(k), xOval1, yOval1)
rowsToKeep(k) = true;
end
if inpolygon(x(k), y(k), xOval2, yOval2)
rowsToKeep(k) = true;
end
end
% Extract only the good points.
x = x(rowsToKeep);
y = y(rowsToKeep);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!