Context. The all-sky survey from the Planck space telescope has revealed that thermal emission from Galactic dust is polarized on scales ranging from the whole sky down to the inner regions of molecular clouds. Polarized dust emission can therefore be used as a probe for magnetic fields on different scales. In particular, the analysis of the relative orientation between the density structures and the magnetic field projected on the plane of the sky can provide information on the role of magnetic fields in shaping the structure of molecular clouds where star formation takes place. Aims. The orientation of the magnetic field with respect to the density structures has been investigated using different methods. The goal of this paper is to explicitly compare two of these: the Rolling Hough Transform (RHT) and the gradient technique (GRAD). Methods. We generated synthetic surface brightness maps at 353 GHz (850 μm) via magnetohydrodynamic simulations. We applied RHT and GRAD to two morphologically different regions identified in our maps. Region 1 is dominated by a dense and thick filamentary structure with some branches, while Region 2 includes a thinner filament with denser knots immersed in a more tenuous medium. Both methods derive the relative orientation between the magnetic field and the density structures, to which we applied two statistics, the histogram of relative orientation and the projected Rayleigh statistic, to quantify the variations of the relative orientation as a function of column density. Results. Both methods find areas with significant signal, and these areas are substantially different. In terms of relative orientations, in all our considered cases the predominant orientation of the density structures is perpendicular to the direction of the magnetic field. When the methods are applied to the same selected areas the results are consistent with each other in Region 2 but show some noticeable differences in Region 1. In Region 1, RHT globally finds the relative orientation becoming more perpendicular for increasing column density, while GRAD, applied at the same resolution as RHT, gives the opposite trend. These disparities are caused by the intrinsic differences in the methods and in the structures that they select. Conclusions. Our results indicate that the interpretation of the relative orientation between the magnetic field and density structures should take into account the specificity of the methods used to determine such orientation. The combined use of complementary techniques such as RHT and GRAD provides more complete information, which can be advantageously used to better understand the physical mechanisms operating in magnetized molecular clouds.