-1

如何将图像分离为三个区域(暗、中、亮)?任何 matlab 命令都可以使用吗?

4

1 回答 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 回答