A list,
Weighted image fusion based on MATLAB
Ii. Source code
clear
g_R=0;
g_G=0;
g_B=0;
h_R=0;
h_G=0;
h_B=0;
fenzi_R=0;
fenzi_G=0;
fenzi_B=0;
fenmu_up_R=0;
fenmu_up_G=0;
fenmu_up_B=0;
fenmu_low_R=0;
fenmu_low_G=0;
fenmu_low_B=0;
tableR=[];
tableG=[];
tableB=[];
up=imread('high.jpg'); Low =imread('low.jpg');
figure(1) imshow(up); % read RGB value [M,N,color]=size(up); title('Weighted -RGB representation of high-resolution images');
figure(2)
imshow(low);
title('Weighted -RGB representation of low resolution images');
r=double(up(:,:,1));
g=double(up(:,:,2));
b=double(up(:,:,3));
r_low=double(low(:,:,1));
g_low=double(low(:,:,2));
b_low=double(low(:,:,3));
RGB(:,:,1) =0.5*r+0.5*r_low;
RGB(:,:,2) =0.5*g+0.5*g_low;
RGB(:,:,3) =0.5*b+0.5*b_low;
R=RGB(:,:,1);
G=RGB(:,:,2);
B=RGB(:,:,3);
RGB=uint8(round(RGB));
figure(3)
imshow(RGB)
title('Weighted -RGB converted image'); % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % is below the average gradient G % calculation % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %for ii=1:M- 1
for jj=1:N- 1
g_R=g_R+sqrt((((r(ii+1,jj)-r(ii,jj))^2+(r(ii,jj+1)-r(ii,jj))^2)) /2);
g_G=g_G+sqrt((((g(ii+1,jj)-g(ii,jj))^2+(g(ii,jj+1)-g(ii,jj))^2)) /2);
g_B=g_B+sqrt((((b(ii+1,jj)-b(ii,jj))^2+(b(ii,jj+1)-b(ii,jj))^2)) /2);
end
end
fprintf('\n\n highR clarity :%.4f\n highG clarity :%.4f\n highG clarity :%.4f' \n highG clarity :%.4f'. g_R/(M- 1)/(N- 1),g_G/(M- 1)/(N- 1),g_B/(M- 1)/(N- 1));
g_R=0;
g_G=0;
g_B=0;
for ii=1:M- 1
for jj=1:N- 1
g_R=g_R+sqrt((((r_low(ii+1,jj)-r_low(ii,jj))^2+(r_low(ii,jj+1)-r_low(ii,jj))^2)) /2);
g_G=g_G+sqrt((((g_low(ii+1,jj)-g_low(ii,jj))^2+(g_low(ii,jj+1)-g_low(ii,jj))^2)) /2);
g_B=g_B+sqrt((((b_low(ii+1,jj)-b_low(ii,jj))^2+(b_low(ii,jj+1)-b_low(ii,jj))^2)) /2);
end
end
fprintf('\n\n lowR :%.4f\n lowG :%.4f\n lowG :%.4f\n lowG :%.4f'. g_R/(M- 1)/(N- 1),g_G/(M- 1)/(N- 1),g_B/(M- 1)/(N- 1));
g_R=0;
g_G=0;
g_B=0;
for ii=1:M- 1
for jj=1:N- 1
g_R=g_R+sqrt((((R(ii+1,jj)-R(ii,jj))^2+(R(ii,jj+1)-R(ii,jj))^2)) /2);
g_G=g_G+sqrt((((G(ii+1,jj)-G(ii,jj))^2+(G(ii,jj+1)-G(ii,jj))^2)) /2);
g_B=g_B+sqrt((((B(ii+1,jj)-B(ii,jj))^2+(B(ii,jj+1)-B(ii,jj))^2)) /2);
end
Copy the code
3. Operation results
Fourth, note
Version: 2014 a