编码曝光知识 - ostartech - 博客园 https://www.cnblogs.com/wxl845235800/p/8276362.html

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% 作者:WWC %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 维纳滤波
clc;
clear;
close all;
%% 读取图片
I=imread('飞机.png');
I2=imfilter(I,[0 0 0 0 0 0 0 0 5/25 4/25 4/25 3/25 3/25 2/25 2/25 1/25 1/25]);
I2=imnoise(I2,'gaussian',0,0.001);
I1=imfilter(I2,[1/9 1/9 1/9;1/9 1/9 1/9;1/9 1/9 1/9;]);
I_hsv=rgb2hsv(I1);
I=I_hsv(:,:,3)*255;
%% 频谱 估计运动模糊方向(光斑的角度与真实图像运动模糊距离垂直)
img_fft=fftshift(fft2(I));
N=abs(img_fft);
P=(N-min(min(N)))/(max(max(N))-min(min(N)))*225;
figure;imshow(P);
%% 估计运动模糊长度(两个最小点之间的距离为近似运动模糊距离)
h=fspecial('sobel');
img_double=double(I);
J=conv2(img_double,h,'same');
IP=abs(fft2(J));
S=fftshift(real(ifft2(IP)));
figure;plot(S);
%% 进行维纳滤波
f = im2double(I);
PSF = fspecial('motion',9,180);% 分别填写上述估计的运动模糊距离和运动模糊方向 为普通相机PSF
%PSF=[0 0 0 0 0 0 0 0 1/25 1/25 2/25 2/25 3/25 3/25 4/25 4/25 5/25];% 编码相机的PSF
frest1 = deconvwnr(f,PSF,0.02);
frest2=cat(3,I_hsv(:,:,1),I_hsv(:,:,2),frest1/255);
frest2=hsv2rgb(frest2);
figure,imshow(I2); title('原图像');
figure,imshow(frest2); title('维纳滤波处理后图像');
imwrite(I2,'原图.jpg');
imwrite(frest2,'普通曝光后滤波.jpg');

假设曝光时间0.2s,在曝光时间内走过的像素点数为为25,均匀分成9份,分别走过的像素点为1 1 2 2 3 3 4 4 5,

则设计36位编码为100010001010101011011011111111111111。

05-11 17:43