简体   繁体   English

无法执行赋值,因为左侧的大小为 512×512,右侧的大小为 512×512×3 MATLAB

[英]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

I am a beginner in MATLAB and am following this code from GitHub related to the classification of lung cancer.我是 MATLAB 的初学者,正在遵循GitHub 中与肺癌分类相关的代码

When I use the sample image in the GitHub link it works fine but when I try to use a different image from the database mentioned on GitHub I am getting the following error.当我使用 GitHub 链接中的示例图像时,它工作正常,但是当我尝试使用 GitHub 中提到的数据库中的不同图像时,出现以下错误。

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.无法执行赋值,因为左侧的大小为 512×512,右侧的大小为 512×512×3。

Error in lung (line 16)肺部错误(第 16 行)

img_out(:,:,n) = imfilter(img_in, gb, 'symmetric'); img_out(:,:,n) = imfilter(img_in, gb, '对称');

Here is the area of code where the error lies这是错误所在的代码区域

%% 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');

I also checked the import wizard and there is definitely something different about the sample image on GitHub and the.dcm image I download and then convert to.bmp.我还检查了导入向导,GitHub 上的示例图像和我下载然后转换为.bmp 的.dcm 图像肯定有一些不同。

The output of img_in = imread('b.bmp'); output of img_in = imread('b.bmp'); is a 512x512x3 RGB image.是一个 512x512x3 的 RGB 图像。 You filter this RGB by imfilter() and return an object of the same size.您通过imfilter()过滤此 RGB 并返回相同大小的 object。 You are then trying to to assign this to a single 512x512 slice of your 512x512x4 img_out array.然后,您试图将其分配给 512x512x4 img_out 数组的单个 512x512 切片。

If the.dcm image is grayscale you should use rgb2gray() to change the size of img_in to a single 512x512 slice.如果.dcm 图像是灰度图像,则应使用rgb2gray()img_in的大小更改为单个 512x512 切片。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法执行分配,因为左侧的大小为 1×2,右侧的大小为 2×2 - 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 indices on the left side are not compatible with the size of the right side 无法执行分配,因为左侧的索引与右侧的大小不兼容。 这是什么意思? - Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. What does this mean? 无法执行分配,因为左侧的索引与右侧的大小不兼容。? - Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.? 在N个昏暗数组上优化MATLAB工作(512,512,400) - Optimizing MATLAB work on N dim array(512,512,400) Matlab中512x512图像中的示例8x8补丁 - Sample 8x8 patch from 512x512 image in Matlab 无法执行分配,因为左侧和右侧的元素数量不同。 MATLAB 错误 - Unable to perform assignment because the left and right sides have a different number of elements. MATLAB ERROR Matlab:无法执行赋值,因为左侧和右侧的元素数量不同 - Matlab: Unable to perform assignment because the left and right sides have a different number of elements 为什么MATLAB的元素指数加速为512个元素? - Why does MATLAB's element-wise exponentiation speed up for 512 elements? 无法执行分配,因为左侧和右侧具有不同数量的元素 - Unable to perform assignment because the left and right sides have a different number of elements
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM