how to save this new images using dicomwrite

1 Ansicht (letzte 30 Tage)
tarek abousaleh
tarek abousaleh am 21 Mär. 2018
Kommentiert: tarek abousaleh am 21 Mär. 2018
I have a programm where i take 4 sets of images, do certain equations on them and after that i would like to save the new set of images in my program (R) to a folder without changing the matrices of R the problem is with dicomwrite (either it is giving me errors and if i change a bit in my program, it gives me another matrices for R from type of UNI and not double). if someone good solve this i would really appreciate it note : i am saving the matrices resultes to my workspace without any problem thanks in advance
for c=1:sizeOfStruct1(1,2)
name1 = fullfile(folder_name1,filesStruct1(c).name);
name2 = fullfile(folder_name2,filesStruct2(c).name);
name3 = fullfile(folder_name3,filesStruct3(c).name);
name4 = fullfile(folder_name4,filesStruct4(c).name);
% Read image from the first fcheckNplotolder, image from the second one,
% convert their matrices to double and store them in A and B.
inv1{c} = double(dicomread(name1));
inv1_pha{c} = double(dicomread(name2));
inv2{c} = double(dicomread(name3));
inv2_pha{c} = double(dicomread(name4));
alpha{c} = ((inv1_pha{c}.*pi)./(4096)) - (pi./2);
beta{c} = ((inv2_pha{c}.*pi)./(4096)) - (pi./2);
metadata = dicominfo(name1);
inv1_com{c} = inv1{c}.* exp(i.*alpha{c});
inv2_com{c} = inv2{c}.* exp(i.*beta{c});
N{c} = inv1_com{c}.* conj(inv2_com{c});
D{c} = abs(inv1_com{c}.^2) + abs(inv2_com{c}.^2);
R{c} = N{c}./D{c};
dicomwrite(R, fullfile('Results',filesStruct1(c).name));
end
save('R');
  3 Kommentare
tarek abousaleh
tarek abousaleh am 21 Mär. 2018
if it does not work like this because i am using a cell array then in this one , ia m not storing the results in my workspace but with dicomwrite it is changing from double to UNI, which leads to a change in the images, here is the code like this:
for c=1:sizeOfStruct1(1,2)
name1 = strcat(folder_name1,'/',filesStruct1(c).name);
name2 = strcat(folder_name2,'/',filesStruct2(c).name);
name3 = strcat(folder_name3,'/',filesStruct3(c).name);
name4 = strcat(folder_name4,'/',filesStruct4(c).name);
% Read image from the first fcheckNplotolder, image from the second one,
% convert their matrices to double and store them in A and B.
inv1 = double(dicomread(name1));
inv1_pha = double(dicomread(name2));
inv2 = double(dicomread(name3));
inv2_pha = double(dicomread(name4));
alpha = ((inv1_pha.*pi)./(4096)) - (pi./2);
beta = ((inv2_pha.*pi)./(4096)) - (pi./2);
metadata = dicominfo(name1);
inv1_com = inv1.* exp(i.*alpha);
inv2_com = inv2.* exp(i.*beta);
N = inv1_com.* conj(inv2_com);
D = abs(inv1_com.^2) + abs(inv2_com.^2);
R = N./D
dicomwrite(R, (strcat('Results/',filesStruct1(c).name)), metadata);
end
tarek abousaleh
tarek abousaleh am 21 Mär. 2018
i would appreciate any help so much cause i have been stuck with this problem for a while

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Denoising and Compression finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by