【MATLAB】读取序列图像raw文件并求序列均值

读取序列图像raw文件并求序列均值

读取16位raw图像,图像大小为640*512,也可自行调整。
matlab代码如下:

%% 初始化
foldname='C:\Users\admin\Desktop\16bit';
frameWidth=640;
frameHeight=512;
listfile=dir(fullfile(foldname,'*.raw'));
frames=length(listfile); % 帧数
image_sequence = zeros(frameHeight,frameWidth,frames); % 序列图像三维数组
%% 读序列图像
for i=1:frames
    filename=listfile(i).name;
    filename=fullfile(foldname,filename);
    fid=fopen(filename,'r');
    data_temp=fread(fid,[frameWidth,frameHeight],'uint16');
    image_raw=data_temp';  
    image_sequence(:,:,i)=image_raw;
    fclose(fid);
end
%% 序列均值
image_mean = mean(image_sequence,3);
image_mean = uint16(image_mean);

你可能感兴趣的:(MATLAB,matlab,均值算法,图像处理)