Crowd object counting and localization are key steps for quantitative analysis in large-scale microscopy applications. Previous methods producing density maps based on deep learning have reached a high level of accuracy for object counting by assuming that object counting is equivalent to the integration of the density map. However, this model fails when objects overlap significantly and/or present fuzzy boundaries regarding accurate localization. To overcome this limitation, we propose an alternative method to count and localize objects from the density map. Our procedure includes the following three key aspects: 1) Proposing a new connected-component analysis method based on the statistical properties of the density map, 2) optimizing the counting results for those objects which are well-detected based on the proposed counting method, and 3) improving localization of poorly detected objects using the proposed counting method as prior information. Validation includes processing microscopy data with known ground truth and comparison with other models that use conventional processing of the density map. Our results show improved performance in counting and localization of objects in 2D and 3D microscopy data. Furthermore, the proposed method is generic, considering various applications that rely on the density map approach.