The theory of compressive sensing (CS) asserts that an unknown signal x in C^N canbe accurately recovered from m measurements with m << N provided that x is sparse. Most of the recovery algorithms need the sparsity s = ||x||_0 as an input. However,generally s is unknown, and directly estimating the sparsity has been an open problem.In this study, an estimator of sparsity is proposed by using Bayesian hierarchical model. Its statistical properties such as unbiasedness and asymptotic normality are proved. Inthe simulation study and real data study, magnetic resonance image data is used asinput signal, which becomes sparse after sparsified transformation. The results fromthe simulation study confirm the theoretical properties of the estimator. In practice, theestimate from a real MR image can be used for recovering future MR images under theframework of CS if they are believed to have the same sparsity level after sparsification.