读取PolSAR中S2矩阵(复数据)

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值