Image mask - apart from rectangle in the center
Show older comments
Hi!
I'm using this code (from the internet) to mask everything outside of the circle. I'm struggeling to adapt this code to replace the circle with a rectangle. Any suggestions?
maskGabor = (img);
[rNum, cNum, ~] = size(maskGabor);
% Define coordiantes and radius
[xx, yy] = ndgrid((1:rNum)-centerY, (1:cNum)-centerX); % generate grid with binary mask
mask = (xx.^2 + yy.^2)>radius^2; % define area outside of cirlce that will be masked
maskGabor(mask) = color; % color is gray
Many thanks, jk
Accepted Answer
More Answers (1)
John Kau
on 29 Jul 2015
Categories
Find more on Region and Image Properties 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!