function [S2] =gxm_read_matlab_s2( FilePath,height,width )
% Read the Matlab format S2 complex file S=[height,2*width]
% S = [real imag];
%
% FilePath : path of data
% height : rows of data
% width :column of data
% S2 : 4-dims[S11 S12 S21 S22]
% Author : gengxm0120@163.com from WuHan University
% Date : 2018/7/17
disp(‘Start to Read The Matlab Format S2 !’);
%% Create the S Array
S11 = complex(rand(height,width),rand(height,width));
S12 = complex(rand(height,width),rand(height,width));
S21 = complex(rand(height,width),rand(height,width));
S22 = complex(rand(height,width),rand(height,width));
if isdir(fullfile(FilePath,’S2’))
delete(fullfile(FilePath,’S2’,’*.tif’));
end
mkdir(fullfile(FilePath,’S2’));
%% Read the S11 from the file using fread.
fileID = fopen(fullfile(FilePath,’S11.bin’));
same_real = fread(fileID, [width,height], ‘double’);
same_real = same_real’;
same_imag = fread(fileID, [width,height], ‘double’);
same_imag = same_imag’;
fclose(fileID);
S2(:,:,1) = complex(same_real, same_imag);
s2(:,:,1) = same_real;
s2(:,:,2) = same_imag;
gxm_imwrite2tif(s2,[],strcat(FilePath,’\S2\’,’s11.tif’),’double’,’Copyright’,’MRI’,…
‘Compression’,1);
clear same_real same_imag
%% Read the S12 from the file using fread.
fileID = fopen(fullfile(FilePath,’S12.bin’));
same_real = fread(fileID, [width,height], ‘double’);
same_real = same_real’;
same_imag = fread(fileID, [width,height], ‘double’);
same_imag = same_imag’;
fclose(fileID);
S2(:,:,2) = complex(same_real, same_imag);
s2(:,:,1) = same_real;
s2(:,:,2) = same_imag;
gxm_imwrite2tif(s2,[],strcat(FilePath,’\S2\’,’s12.tif’),’double’,’Copyright’,’MRI’,…
‘Compression’,1);
clear same_real same_imag
%% Read the S21 from the file using fread.
fileID = fopen(fullfile(FilePath,’S21.bin’));
same_real = fread(fileID, [width,height], ‘double’);
same_real = same_real’;
same_imag = fread(fileID, [width,height], ‘double’);
same_imag = same_imag’;
fclose(fileID);
S2(:,:,3) = complex(same_real, same_imag);
s2(:,:,1) = same_real;
s2(:,:,2) = same_imag;
gxm_imwrite2tif(s2,[],strcat(FilePath,’\S2\’,’s21.tif’),’double’,’Copyright’,’MRI’,…
‘Compression’,1);
clear same_real same_imag
%% Read the S22 from the file using fread.
fileID = fopen(fullfile(FilePath,’S22.bin’));
same_real = fread(fileID, [width,height], ‘double’);
same_real = same_real’;
same_imag = fread(fileID, [width,height], ‘double’);
same_imag = same_imag’;
fclose(fileID);
S2(:,:,4) = complex(same_real, same_imag);
s2(:,:,1) = same_real;
s2(:,:,2) = same_imag;
gxm_imwrite2tif(s2,[],strcat(FilePath,’\S2\’,’s22.tif’),’double’,’Copyright’,’MRI’,…
‘Compression’,1);
clear same_real same_imag
%%
% S2 = cat(3,S11,S12,S21,S22);
% clear S11 S12 S21 S22;
disp(‘The Matlab Format S2 is Read!’);
end
读取PolSAR中S2矩阵(复数据)
最新推荐文章于 2024-05-27 15:52:04 发布