  We present a general expression for a lognormal filter given an arbitrary
nonlinear galaxy bias. We derive this filter as the maximum a posteriori
solution assuming a lognormal prior distribution for the matter field with a
given mean field and modeling the observed galaxy distribution by a Poissonian
process. We have performed a three-dimensional implementation of this filter
with a very efficient Newton-Krylov inversion scheme. Furthermore, we have
tested it with a dark matter N-body simulation assuming a unit galaxy bias
relation and compared the results with previous density field estimators like
the inverse weighting scheme and Wiener filtering. Our results show good
agreement with the underlying dark matter field for overdensities even above
delta~1000 which exceeds by one order of magnitude the regime in which the
lognormal is expected to be valid. The reason is that for our filter the
lognormal assumption enters as a prior distribution function, but the maximum a
posteriori solution is also conditioned on the data. We find that the lognormal
filter is superior to the previous filtering schemes in terms of higher
correlation coefficients and smaller Euclidean distances to the underlying
matter field. We also show how it is able to recover the positive tail of the
matter density field distribution for a unit bias relation down to scales of
about >~2 Mpc/h.
