Clear Filters
Clear Filters

plot orientations using quiver only in the mask region...

3 views (last 30 days)
[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"...

Accepted Answer

Image Analyst
Image Analyst on 20 Feb 2017
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);

More Answers (0)

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!