Main Content

imfilter 경계선 채우기 옵션

영상 경계선에서의 출력 픽셀을 계산할 때, 아래 그림에 설명된 것처럼 일반적으로 컨벌루션 또는 상관 커널의 일부가 영상 경계에서 벗어나게 됩니다.

커널 값이 영상을 벗어나는 경우

A grid of pixels displaying the pixel values. The 3-by-3 kernel centered on the (1, 4) pixel is highlighted in gray and extends past the edge of the image, where there are no pixels.

imfilter 함수는 일반적으로 경계를 벗어난 영상 픽셀을 0으로 가정하고 채웁니다. 이를 0 채우기라고 하며 다음 그림에 표시되어 있습니다.

범위를 벗어난 픽셀의 0 채우기

A grid of pixels displaying the pixel values. Pixels are simulated where the 3-by-3 kernel extends past the edge of the image. The value of the simulated pixels is 0.

영상을 필터링할 때 0 채우기를 수행하면 이 예제에 나와 있는 것처럼 영상 경계 주변에 짙은 띠가 생길 수 있습니다.

I = imread("eight.tif");
h = ones(5,5) / 25;
I2 = imfilter(I,h);
imshow(I)
title("Original Image");
figure
imshow(I2)
title("Filtered Image with Black Border")

On the left is the original image and on the right is the filtered image with dark pixels along the edge of the image.

0 채우기로 인한 영상 경계 주변의 아티팩트를 제거할 수 있도록 imfilter테두리 복제라는 또 다른 경계선 채우기 방법을 제공합니다. 테두리 복제 시 영상을 벗어난 픽셀 값은 가장 가까운 테두리 픽셀의 값을 복제하는 방법으로 결정됩니다. 이에 대해 다음 그림에 설명되어 있습니다.

복제된 경계선 픽셀

A grid of pixels displaying the pixel values. Pixels are simulated where the 3-by-3 kernel extends past the edge of the image. The value of each simulated pixel is equal to the value of the edge pixel adjacent to the simulated pixel.

테두리 복제를 사용해 필터링하기 위해 선택적 추가 인수 "replicate"imfilter에 전달합니다.

I3 = imfilter(I,h,"replicate");
figure
imshow(I3); 
title("Filtered Image with Border Replication")

The filtered image with border replication does not have dark pixels along the edge of the image.

imfilter 함수는 "circular", "symmetric" 같은 다른 경계선 채우기 옵션도 지원합니다.

참고 항목

관련 항목