有没有什么好方法可以分配一些具有相同颜色的蒙版像素,除了for-loop
?
%% pick a color
cl = uisetcolor; %1-by-3 vector
im = ones(3, 3, 3) / 2; % gray image
mask = rand(3, 3);
mask_idx = mask > 0.5; % create a mask
%% Something like this
im(mask_idx, :) = cl'; % assignment the pixels to color `cl`