2
除了for-loop
之外,有沒有什麼好的方法去分配一些相同顏色的蒙版像素?Pixel-wise like assignment在Matlab中
%% 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`
你可以重塑你的形象,應用面具,並重塑形狀......如果這就是你的意思 – bla
@natan我已經使用'repmat()'添加了我自己的解決方案,但它有點尷尬。如果你使用'reshape()'更簡單的解決方案,我很樂意看到它。 – user1884905
需要'reshape','permute'和'repmat'的組合。看看他們所有的文件。 – rwong