如何将DICOM文件转换为RGB文件?



我将在Matlab中解释我的问题。我有一个多帧的DICOM文件,70x70x50。我想把它转换成RGB

这是我的代码:

clear all;
close all;
clc;
% Lettura Dicom
img = dicomread('provaDICOM.dcm'); % 4-D int16
info = dicominfo('provaDICOM.dcm');
img2 = squeeze(img); % 70x70x50 int16
img3 = mat2gray(img2); % 70x70x50 double
% volumeViewer(img2);
% Conversione RGB
cmap = copper(256);
numslice = size(img3,3);
colored_MHA = zeros(size(img3, 1), size(img3, 2), numslice, 3);
for slice = 1 : numslice
colored_MHA(:,:,slice) = ind2rgb(img3(:,:,slice), cmap);
end

错误:

Unable to perform assignment because the size of the left side is 70-by-70 and the size of the right side is
70-by-70-by-3.
Error in Dicom (line 18)
colored_MHA(:,:,slice) = ind2rgb(img3(:,:,slice), cmap);

您需要在colored_MHA上引用一个额外的维度。

试题:

colored_MHA(:,:,:,slice) = ind2rgb(img3(:,:,slice), cmap);

一般来说,这个错误告诉你,你试图把一个大的东西放到一个太小的东西里,当你看到这个错误时,你可以问自己为什么会这样。

相关内容

最新更新