function f_threshold(file_name)
% Evan Ruzanski and Chiou-Wei Tsai
% UCSB, 11/3/2003
clc
% Initialize variables
thresh = 77;
gray_range = 256;
% Read and display test image as given in Lee, p. 712
im = imread(file_name);
figure
imshow(im); title('Original 2D image');
% Perform binary spatial lifting
s = size(im);
imz(1:s(1),1:s(2),1:gray_range) = 0;
im = double(im); % Typecast for arithmetic operations
for i = 1:s(1)
for j = 1:s(2)
if im(i,j) > 1
imz(i,j,1:im(i,j)) = 1; % Make 3rd Dim binary
end
end
end
% 3D representation of lifting the image
figure(2)
x = 1:s(1);
y = 1:s(2);
[X,Y] = meshgrid(x,y);
colormap(gray)
rotate3d
mesh(X,Y,im); axis tight
title('Lifted representation of 2D image')
% Take 3D FFT of binary lifted data
IMZT = fftn(imz);
% Slice and extract
S = size(IMZT);
un = [zeros(1,thresh - 1) ones(1,S(3) - (thresh - 1))]; % Create unit step
U = fft(un);
for i = 1:S(1),
for j = 1: S(2),
IM2D(i, j) = IMZT(i,j,:)*U';
end
end
% Recover and disply 2D image
im2d = ifft2(IM2D);
im2d = 1/256*fix(real(im2d));
figure
imshow(uint8(im2d)); title('Thresholded image');
- 1
- 2
- 3
- 4
前往页