![](/img/trans.png)
[英]Unable to perform assignment because the size of the left side is 1-by-2 and the size of the right side is 2-by-2
[英]Unable to perform assignment because the size of the left side is 512-by-512 and the size of the right side is 512-by-512-by-3 MATLAB
我是 MATLAB 的初学者,正在遵循GitHub 中与肺癌分类相关的代码。
当我使用 GitHub 链接中的示例图像时,它工作正常,但是当我尝试使用 GitHub 中提到的数据库中的不同图像时,出现以下错误。
无法执行赋值,因为左侧的大小为 512×512,右侧的大小为 512×512×3。
肺部错误(第 16 行)
img_out(:,:,n) = imfilter(img_in, gb, '对称');
这是错误所在的代码区域
%% Preprocessing using gabor filter for image enhancement
lambda = 9;
theta = 0;
bw = 3;
psi = [0 0];
gamma = 2;
N = 4;
img_in = imread('b.bmp');
%img_in = double(dicomread('b.dcm'));
%img_in(:,:,2:3) = [];
img_out = zeros(size(img_in,1), size(img_in,2), N);
for n=1:N
gb = gabor_fn(bw,gamma,psi(1),lambda,theta)...
+ gabor_fn(bw,gamma,psi(2),lambda,theta);
img_out(:,:,n) = imfilter(img_in, gb, 'symmetric');
theta = theta + pi/4;
end
figure(1);
imshow(img_in);
title('input image');
figure(2);
img_out_disp = sum(abs(img_out).^2, 3).^0.5;
img_out_disp = img_out_disp./max(img_out_disp(:));
imshow(img_out_disp);
title('gabor output, L-2 super-imposed, normalized');
我还检查了导入向导,GitHub 上的示例图像和我下载然后转换为.bmp 的.dcm 图像肯定有一些不同。
output of img_in = imread('b.bmp');
是一个 512x512x3 的 RGB 图像。 您通过imfilter()
过滤此 RGB 并返回相同大小的 object。 然后,您试图将其分配给 512x512x4 img_out 数组的单个 512x512 切片。
如果.dcm 图像是灰度图像,则应使用rgb2gray()
将img_in
的大小更改为单个 512x512 切片。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.