Hi; i need help please. I want to multiply the 5 slices i chose from image vol (1) * slices from image vol (3) and (img2 * img4) this program displays as (img2 * img4) , I wan
3 次查看(过去 30 天)
显示 更早的评论
clear all;
close all;
a='C:\Users\HP_2\Desktop\Nouveau dossier (2)'
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
for p=2:2:4
jpgfiles=dir(fullfile(a,'\*.nii*'));
n=numel(jpgfiles(p));
im=jpgfiles(p).name
img=niftiinfo(fullfile(a,im));
Va = niftiread(img);
Va_prime = mat2gray(Va);%Convertir la matrice en image en niveaux de gris
[sliceX sliceY sliceZ]=size(Va);
frontal = Va_prime; % Frontal view
for i=1:sliceZ
outslice=frontal(:,:,i);
outslice=imrotate(outslice,90);
x(i)=bwarea(outslice);
y=max(x);
c=find(x==y);
end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
for p=1:2:3
jpgfiles=dir(fullfile(a,'\*.nii*'));
n=numel(jpgfiles(p));
im=jpgfiles(p).name
img=niftiinfo(fullfile(a,im));
Va = niftiread(img);
Va_prime = mat2gray(Va);%Convertir la matrice en image en niveaux de gris
[sliceX sliceY sliceZ]=size(Va);
frontal1 = Va_prime; % Frontal view
for i=1:sliceZ
outslice=frontal1(:,:,i);
outslice=imrotate(outslice,90);
end
end
for m=-2:2
x=(imrotate(frontal1(:,:,c+m),90)).*(imrotate(frontal(:,:,c+m),90));
figure,imshow(x);
end
4 个评论
Walter Roberson
2021-6-18
Do you want to use element-by-element multiplication with the .* operator, or do you want to use algebraic matrix multiplication with the * operator?
What difficulty are you facing in reaching your goal?
回答(1 个)
Walter Roberson
2021-6-18
You have
for p=1:2:3
jpgfiles=dir(fullfile(a,'\*.nii*'));
n=numel(jpgfiles(p));
im=jpgfiles(p).name
img=niftiinfo(fullfile(a,im));
Va = niftiread(img);
Va_prime = mat2gray(Va);%Convertir la matrice en image en niveaux de gris
[sliceX sliceY sliceZ]=size(Va);
frontal1 = Va_prime; % Frontal view
for i=1:sliceZ
outslice=frontal1(:,:,i);
outslice=imrotate(outslice,90);
end
end
for m=-2:2
x=(imrotate(frontal1(:,:,c+m),90)).*(imrotate(frontal(:,:,c+m),90));
figure,imshow(x);
end
Notice that the for p loop ends before the for m loop, and that you have not displayed anything in the for j loop. Your only display is inside the for m loop, which is why you only get 5 outputs and not 5 for each different p value.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!