  The classical image segmentation algorithm based on grayscale morphology can
effectively segment images with uneven illumination, but with the increase of
the image data, the real-time problem will emerge. In order to solve this
problem, a quantum image segmentation algorithm is proposed in this paper,
which can use quantum mechanism to simultaneously perform morphological
operations on all pixels in a grayscale image, and then quickly segment 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 NEQR images. For a 2^n * 2^n
image with q grayscale levels, the complexity of our algorithm can be reduced
to O(n^2+q), 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 (NISQ) era.
