2017-09-08 14 views
1

Matlab/Octave(Imageパッケージ)では、画像領域上にわずかに透明な色の矩形を描くことは可能ですか?透明で画像上にマスクを描画

たとえば、画像の左上隅に赤い矩形(アルファ/不透明度0.5)を描きたい。

pkg load image; 
pkg load signal; 

i = imread('foo.jpg'); 

% Somehow draw a transparent rectangle over the top left of the image 

imshow(i); 
+1

。そのような "Matlab/Octave"のことはありません。そしてはい、可能です。ちょうど矩形をiの3次元に追加します – Andy

答えて

1

次のように透明オーバーレイを描画するhold onとプロパティ'AlphaData'を使用することができます。

可能な場合は、GNU Octaveのか、Matlabのためのソリューションが必要な場合は、明示的に言うべき
image = rand(100); % a random image 
imshow(image); % show the image 

% create the red overlay 
red = zeros(100, 100, 3); 
red(:, :, 1) = 1; 

% create the alpha channel with the right transparency 
alpha = zeros(100); % everywhere completely transparent 
alpha(1:50, 1:50) = 0.5; % except for the top left corner 

hold on 
h = imshow(red); % show the overlay 
set(h, 'AlphaData', alpha); % apply the transparency 

enter image description here

関連する問題