[英]How do I convert a DICOM file into RGB?
I'll explain my problem in Matlab.我将在 Matlab 中解释我的问题。 I have a multi-frame DICOM file, 70x70x50.
我有一个多帧 DICOM 文件,70x70x50。 I would like to convert it to RGB.
我想将其转换为 RGB。
This is my code:这是我的代码:
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
This is the error:这是错误:
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);
You need to reference an extra dimension on colored_MHA
.您需要在
colored_MHA
上引用一个额外的维度。
Try:尝试:
colored_MHA(:,:,:,slice) = ind2rgb(img3(:,:,slice), cmap);
More generally - the error is telling you that you're trying to put something big into something too small, and when you see this you can ask yourself why that is.更一般地说 - 错误告诉您您正在尝试将大的东西放入太小的东西中,当您看到这一点时,您可以问自己为什么会这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.