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 visualización (últimos 30 días)
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 comentarios
Walter Roberson
Walter Roberson el 18 de Jun. de 2021
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 el 18 de Jun. de 2021
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).

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 18 de Jun. de 2021
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.

Categorías

Más información sobre Images en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by