我想用下面的代码在MATLAB中读取100个不同的MRI图像:
% Preallocate the 256-by-256-by-1-by-20 image array.
X = repmat(int16(0), [256 256 1 20]);
% Read the series of images.
for p=1:20
filename = sprintf('brain_%03d.dcm', p);
X(:,:,1,p) = dicomread(filename);
end
% Display the image stack.
montage(X,[])但是这个错误出现了:
子脚本赋值维度不匹配。
这个代码有什么问题?
发布于 2022-03-30 13:43:40
% Please Include Your MATLab Error :)您有一个订阅的赋值维度不匹配,这意味着加载我们的sprintf()不是大小(256x256)。
还有,就像一个人
X(:,:,1,p)这使用了错误的维度..。
假设您想要存储一个4行4 cols图像。强度在0到255之间。总共有16个元素,每个元素都有一个独特的强度值。
当你说(:,:,1)时,你说的是N维,N维,1维。
如果我有一个4x4,我想保存它,我会说([1:4],[1:4],1) -我会保存它。
通过使用X(:,:,1,p) --您正在创建一组图像的集。
你真正想要的只是一组图像。
希望这能有所帮助。
而且,这感觉像一个https://www.chegg.com/homework-help/questions-and-answers/15-points-preallocate-one-dimensional-array-storing-time-measurements-initialize-random-nu-q57567188,所以我没有包括一个直接的解决方案,试图解释您的错误。~最佳
https://stackoverflow.com/questions/71678177
复制相似问题