function y = threshold(x, th)
% y = threshold(x, th)
% Threshold to set the components of x smaller than th to 0
%
%   For any commercial use of this program, a written permission can be 
%   obtained from the authors. please email: phao@eecs.qmul.ac.uk
%
%   If this program is used for research, please cite in your publications:
%
%   * Pengwei Hao, Yan Li, Zhouchen Lin, and Eric Dubois, "A Geometric
%     Method for Optimal Design of Color Filter Arrays", IEEE Transactions
%     on Image Processing, Vol.20, No.3, pp.709-722, March 2011.
%
%   * Yan Li, Pengwei Hao, and Zhouchen Lin, "The Frequency Structure Matrix: 
%     A Representation of Color Filter Arrays", International Journal 
%     of Imaging Systems and Technology, Vol.21, No.1, pp.101-106, 2011.
%
%   By Pengwei Hao and Yan Li, 2007-2012

y = real(x) .* (abs(real(x))>th) + i*imag(x) .* (abs(imag(x))>th);

end

