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

1 次查看(过去 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
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?
Meriem YOUss
Meriem YOUss 2021-6-18
I'm going to make a loop to display the 5 slices multiply from 1st image * 3rd image and the 5 slices multiply from 2nd image * 4th image. the operation I did it works but only displays the 5 slices of (img2 * img4).

请先登录,再进行评论。

回答(1 个)

Walter Roberson
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.

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by