MATLAB に 2336x3504 RGB uint8 ファイルがあります。また、インデックス表記 (2336x3504 のバイナリ イメージに基づく) の対象ピクセルで構成されるベクトルもあります。対象のピクセルに対応する RGB イメージ内のすべてのポイントを特定の色に設定したいと考えています。
私が最初に考えたのは、次のことを行うことでした。
% Separate RGB image into three 3 uint8 arrays.
RGB1 = RGBImage(:,:,1);
RGB2 = RGBImage(:,:,2);
RGB3 = RGBImage(:,:,3);
% Change each layer based on the color I want (say for red, or [255 0 0])
RGB1(interestPixels) = 255;
RGB2(interestPixels) = 0;
RGB3(interestPixels) = 0;
% Then put it all back together
NewRGBImage = cat(3,RGB1,RGB2,RGB3);
これは機能しますが、面倒なようです。もっとエレガントな解決策があると確信していますが、私にはわかりません。