如何使用 Matlab 重新调整灰度 3 维图像 (x,y,z) 的强度范围

How to rescale the intensity range of a grayscale 3 dimension image (x,y,z) using Matlab

我在网上找不到有关由多个 2D 图像组成的 3D 图像的强度重新缩放的信息。

我正在寻找与 imadjust 相同的函数,它仅适用于 2D 图像。

我的 3D 图像是 2D 图像叠加在一起的组合,但我必须处理 3D 图像而不是一张一张地处理 2D 图像。

我无法循环播放 imadjust,因为我想将图像作为一个整体进行处理,以考虑各个方向的所有可用信息。

为了将 imadjust 应用于考虑整体值的 2D 灰度图像集,此技巧可能有效

a = imread('pout.tif');  
a = imresize(a,[256 256]);   %// re-sizing to match image b's dimension
b = imread('cameraman.tif');

Im = cat(3,a,b);     
%//where a,b are separate grayscale images of same dimensions
%// if you have the images separately you could edit this line to
%// Im = cat(2,a,b);
%// and also avoid the next step

%// reshaping into a 2D matrix to apply imadjust
Im = reshape(Im,size(Im,1),[]);

out = imadjust(Im);     %// applying imadjust

%// finally reshaping back to its original shape
out = reshape(out,size(a,1),size(a,2),[]);  

检查:

x = out(:,:,1);
y = out(:,:,2);

正如您从工作区图像中看到的那样,第一张图像(变量 x)没有重新缩放到 0-255,因为它之前的范围(变量 a)没有在0点附近。

工作空间:


编辑: 您可以像这样一步完成:(如其他答案所建议的那样)

%// reshaping to single column using colon operator and then using imadjust
%// then reshaping it back
out = reshape(imadjust(Image3D(:)),size(Image3D));

编辑2:

由于您在 I2 中将图像作为元胞数组,请尝试以下操作:

I2D = cat(2,I2{:})

对 3D 图像执行此操作的唯一方法是将数据视为矢量,然后重新整形。

像这样:

%create a random 3D image.
x = rand(10,20,30);

%adjust intensity range
x_adj = imadjust( x(:), size(x) );