관리 메뉴

Bull

[Image Processing] Banded Notch Filter 본문

Computer Science/Image Processing

[Image Processing] Banded Notch Filter

Bull_ 2024. 5. 8. 15:12

https://codcost.tistory.com/137

 

[Image Processing] Gaussian and Butterworth Notch Filter

과제우선 학교 과제로 한건데, 자료도 없고,,, 지식도 없어서 GPT한테 땡깡 부리면서 만들었다. 정확히 맞는 건지는 모르지만 대략적으로 적용된 거 같아서 포스팅으로 남긴다.요구 사항우선 "무

codcost.tistory.com

이전 글과 연계되는 과제이므로 간략하게 적겠다.

 

요구사항

satrun.jpg

우주에서 찍은 토성 고리사진이다.

 

위성에서 전달받아 우주에 있는 잡음에 의해 사진이 손상되었다.

 

주파수 영역을 확인하고 에너지가 큰 부분(흰색 영역)을 filter로 가려보자.

 

banded notch filter 공식은 따로 없고 표기를 위한 공식만 있다.

 

그냥 식 대입하면서 주파수 영역을 가려주면 된다.

결과


Code


clear;
clc;

im = imread('saturn.jpg');
im = uint8(mean(im, 3));

% parameter
r = size(im, 1);
c = size(im, 2);

center_col = ceil(c / 2);
center_row = ceil(r/2);

[U, V] = meshgrid(1:c, 1:r);
U = U - ceil(c/2);

% % % % % % % % % % % % % % % % % % % % % 
% notch reject filter
H1 = ones(r, c);
H1(1:center_row-4, center_col-1:center_col+1) = 0;
H1(center_row+4:end, center_col-1:center_col+1) = 0;
F = fft2(im);
F_shifted = fftshift(F);
mtrans = F_shifted .* H1;
out1 = abs(ifft2(ifftshift(mtrans)));

% notch passed filter
H2 = zeros(r, c);
H2(1:center_row-4, center_col-1:center_col+1) = 1;
H2(center_row+4:end, center_col-1:center_col+1) = 1;
F = fft2(im);
F_shifted = fftshift(F);
mtrans = F_shifted .* H2;
out2 = abs(ifft2(ifftshift(mtrans)));
% % % % % % % % % % % % % % % % % % % % % 

%output
subplot(3, 2, 1);
imshow(im, []);
title('Original Image');

subplot(3, 2, 2);
imshow(log(abs(F_shifted) + 1), []);
title('Frequency spectrum');

subplot(3, 2, 3);
imshow(log(1 + abs(H1)), []);
title('Notch Reject Filter function');

subplot(3, 2, 4);
imshow(out1, []);
title('Filtered image');

subplot(3, 2, 5);
imshow(log(1 + abs(H2)), []);
title('Notch pass filter function');

subplot(3, 2, 6);
imshow(out2, []);
title('Output of the notched passed filtered image');