![](/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.