我学会了如何做但现在不记得了,而且我没有通过搜索获得有用的东西。我有一个图像,并希望使用此图像通过简单地堆叠它们来创建大小为3x3的更大图像。必须对边框进行平滑处理,以使图像的右边缘无缝转换到图像的左边缘。
应用卷积滤波器应该能够做到这一点,因为它认为图像是圆形的,但我们究竟应该怎么做呢?我们可以说Matlab(或任何其他您喜欢说/打字的语言)。
编辑1: 我更喜欢只将滤镜应用到边框,同时尽可能保留原始图像。
编辑2:
我尝试过高斯滤波器。虽然它模糊整个图像,但与模糊的中间相比,边缘变得更加突出。
imshow(repmat(imfilter(imread('un1vY.jpg'), fspecial('gaussian',64,8), 'circular'), [3 3]))
答案 0 :(得分:1)
这是一个完整的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
答案 1 :(得分:0)