The classical image segmentation algorithm based on grayscale morphology can effectively segment images with uneven illumination, but with the increase of image data, the real-time problem will emerge. In order to solve this problem, a quantum image segmentation algorithm is proposed in this article, which can use a quantum mechanism to simultaneously perform morphological operations on all pixels in a grayscale image, and which then quickly segments the image into a binary image. In addition, several quantum circuit units, including dilation, erosion, bottom-hat transformation, top-hat transformation, etc., are designed in detail, and then, they are combined together to construct the complete quantum circuits for segmenting the novel enhanced quantum representation images. For a <inline-formula><tex-math notation="LaTeX">$2^{n} \times 2^{n}$</tex-math></inline-formula> image with <inline-formula><tex-math notation="LaTeX">$q$</tex-math></inline-formula> grayscale levels, the complexity of our algorithm can be reduced to O<inline-formula><tex-math notation="LaTeX">$(n^{2}+q)$</tex-math></inline-formula>, which is an exponential speedup than the classic counterparts. Finally, the experiment is conducted on IBM Q to show the feasibility of our algorithm in the noisy intermediate-scale quantum era.