Context. The quiet Sun is an important part of understanding the global magnetic properties of the Sun. A recently launched observation system, named HINODE, provides a lot of high-resolution images for studying the quiet Sun. Obviously, it is time-consuming to analyze these images by hand. It is desirable to develop a technique for recognizing magnetic elements, thus automatically computing magnetic properties and the relationship between magnetic elements and granulation. Aims. We design an automatic method of recognizing magnetic elements based on the features of HINODE magnetograms and of measuring their properties. Then we study the relationship between magnetic elements and granulation. Methods. We used the magnetogram, continuum image, and Dopplergram on April 16, 2007, which were taken with the Solar Optical Telescope instrument aboard HINODE. The field of view is 147. 60 × 162. 30 in a quiet solar region, locating at disk center. We introduced the mark-controlled watershed method to detect magnetic elements automatically, because it is a popular image-segmentation method for dealing with overlapping objects. We took the centers that are the local maximum in all directions as the marks for restraining over-segmentation. We computed the properties of the detected magnetic elements and the relation among magnetic field strength, relative continuum intensity, and Doppler velocity at the same locations of magnetic elements. Results. We obtain the following results: (1) 34% of our observation region are covered by magnetic fields; (2) the magnetic flux distribution of all elements reaches a peak at 1.07 × 10 16 Mx for the whole region; (3) the relative continuum intensity distribution at the locations of magnetic elements reaches a peak at 0.97, which shows that the majority of magnetic elements located at the areas where the relative continuum intensity is less than its average. The relative continuum intensities in the areas with strong flux density are the median, meaning that the strong magnetic elements are usually located at the boundary of granulation; (4) the absolute Doppler velocity distribution at the locations of magnetic elements reaches a peak at 1.00 km s −1 , and the majority of weak magnetic elements located at the areas where the absolute velocity is greater than 1.00 km s −1 ; (5) strongly magnetized regions only have weak absolute Doppler velocities. The absolute velocity is lower than 1.00 km s −1 in the regions where the magnetic flux density of elements is higher than 100 G.