Highpass filter type Butterworth

4 views (last 30 days)
Magdalena
Magdalena on 2 Sep 2014
Read 'cameraman.tif' and convert it to a double, then filter it with a highpass Butterworth filter (in a frequency domain) , cutoff frequency 40 px and level 5. Binarize (level 0.1, highpass). Find all the pixels 20 px above the closest 'true' pixel. Count the number of isolated territories and their areas. Is ot correct?
if true
img = imread('cameraman.tif');
img = double(img)/255;
fft = fftshift(fft2(img));
N = 5; D0 = 40; D = zeros(256); H = zeros(256);
for kz=1:256
for kx=1:256
%Butterworth
D(kz,kx) = sqrt( (kz-128)^2 + (kx-128)^2);
H(kz,kx) = 1/(1+(D(kz,kx)/D0)^2*N);
end
end
filtered = fft.*(1-H);
result = ifft2(ifftshift(filtered)); figure; subplot(121); imshow(img); title('Oryginalny'); subplot(122); imshow(result); title('Przefiltrowany');
binarized = im2bw(real(result), 0.1);
ilosc= bwdist(binarized)>20 ; ilosc=sum(ilosc(:)) figure; imshow(binarized); title('Zbinaryzowany');
w = binarized == 1; b = binarized == 0; biale = sum(w(:)); czarne = sum(b(:));
[blab, blobs] = bwlabel(binarized); end

Answers (0)

Community Treasure Hunt

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

Start Hunting!