这里是一个完整的3x3样本:
function Test()
close all
I = imread('un1vY.jpg');
I = double(I)/255; %Convert uint8 to double
J = HorizFuse(I);
Jtag = cat(3, J(:,:,1)', J(:,:,2)', J(:,:,3)'); %Transpose across 2'nd dimension.
K = HorizFuse(Jtag);
K = cat(3, K(:,:,1)', K(:,:,2)', K(:,:,3)'); %Transpose back
K = uint8(K*255); %Convert back to uint8
figure;imshow(K);
imwrite(K, 'K.jpg');
end
function K = HorizFuse(I)
h = linspace(0,1,100); %Create ramp from 0 to 1 of 100 elements.
im_w = size(I, 2); %Image width
im_h = size(I, 1); %Image height
Hy = repmat(h, [size(I, 1), 1, 3]); %Replicate h to fit image height.
J = zeros(im_h, im_w*2-100, 3);
J(:, 1:im_w-100, :) = I(:, 1:im_w-100, :); %Fill pixels from the left to overlap.
J(:, im_w+1:end, :) = I(:, 101:end, :); %Fill pixels from the right of overlap.
%Fill overlap with linear intepolation between right side of left image and left side of right image.
J(:, im_w-99:im_w, :) = I(:, end-99:end, :).*(1-Hy) + I(:, 1:100, :).*Hy;
K = zeros(im_h, im_w*3-100*2, 3);
K(1:size(J,1), 1:size(J,2), :) = J;
K(1:size(J,1), end-(im_w+100)+1:end, :) = J(1:size(J,1), end-(im_w+100)+1:end, :);
end
结果:
什么是宪法过滤器? – rayryeng
拼写检查...卷积 – hyiltiz
我想你在谈论'convolve2d'在Python用'边界='与'circular' wrap''或'imfilter'在MATLAB。 – beaker