이미이 작업을 수행하는 함수를 구현했지만 루프가 필요하지 않습니다. 그러나 루프를 피할 수있는 방법은 없습니다. 호기심이 더 좋은 방법이 있다면.효율적으로 MATLAB 이미지의 픽셀 목록을 페인트하는 방법은 무엇입니까?
function [ colored_img ] = colorImg (img, ix, c)
% function [ colored_img ] = colorImg (img, ix, c)
%
% INPUTS
% img - a 3D array representing the image to color.
% ix - the indexes of the pixels to set to a new color.
% c - a vector representing the color to paint the pixels ix.
%
% OUTPUTS
% colored_img - the colored image.
colored_img = img;
for jx = 1 : numel(c);
a = colored_img(:,:,jx);
a(ix) = c(jx);
colored_img(:,:,jx) = a;
end
end
3 차원이란 무엇입니까? (R, G, B)? –