画像を 3 つの領域 (暗い、中間、明るい) として分離するにはどうすればよいですか?そのために使用できる matlab コマンドはありますか?
1 に答える
0
画像処理ツールボックスには、色に基づいて画像をセグメント化するためのいくつかのオプションがあります。詳細はこちら。強度に基づいてピクセルを選択するだけでよい場合は、ブール演算子を使用できます。そのアプローチの例を次に示します。
% create an example image with three regions of intensity
im = ones(100,100);
im(1:25, 1:30) = 256;
im(75:end, 7:end) = 128;
% add some random noise
im = im + 10*rand(size(im));
% display image
figure
subplot(2,2,1)
image(im)
colormap gray
% segment image based on intensity
bottomThird = 256/3;
topThird = 2*256/3;
index1 = find(im < bottomThird);
index2 = find(and((im > bottomThird),(im <topThird)));
index3 = find(im > topThird);
%create images for each segmented region
im1 = ones(size(im));
im2 = ones(size(im));
im3 = ones(size(im));
im1(index1) = 0;
im2(index2) = 0;
im3(index3) = 0;
%display sub-regions
subplot(2,2,2)
imagesc(im1)
subplot(2,2,3)
imagesc(im2)
subplot(2,2,4)
imagesc(im3)
于 2013-03-25T01:13:36.970 に答える