Alleviate the border effect through extension by repetition and extension by mirroring on image

2 views (last 30 days)
Hello!
Can someone please explain to me what exactly means the following request on my homework and how could I implement it?
"For the previous exercise implement code to alleviate the border effect through extension by repetition and extension by mirroring. Display the result of the filtering with and without the border effect for each photo".
I'm not quite sure to what it is reffering when it comes to extension by repetition and extension by mirroring in regards to alleviating the border effect. I'm thinking of adding a Laplacian effect on the imagine, although I'm not 100% sure.
Thank you!

Answers (1)

DGM
DGM on 29 Oct 2022
Edited: DGM on 29 Oct 2022
To see the border effect in question, consider the following example.
% a 2D image
inpict = imread('cameraman.tif');
% a simple filter kernel
fk = ones(11)/11^2;
% pad the input image by the filter half-width
hw = floor([size(fk,1) size(fk,2)]/2);
inpict = padarray(inpict,hw,'symmetric','both');
% do basic convolution
inpict = im2double(inpict);
outpict = conv2(inpict,fk,'same');
outpict = im2uint8(outpict);
% crop the padding back off the array
% if you're writing the convolution routine yourself,
% this can be obviated by simply choosing appropriate loop indexing
outpict = outpict(hw(1)+1:end-hw(1),hw(2)+1:end-hw(2));
imshow(outpict)
Assuming a zero-padded array, the edges of the result will be darkened by the padding.
This effect can be reduced by either replicating the edge content during padding:
inpict = padarray(inpict,hw,'replicate','both');
... or by reflecting the edge content:
inpict = padarray(inpict,hw,'symmetric','both');
... instead of using zero-padding.
Tools like imfilter() have options to specify which padding method is used internally. By default, imfilter() uses zero-padding.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!