def raster_erosion(rasterfile):
        """Erode the raster image.

         Find the min pixel's value in 8-neighborhood. Then change the compute
         pixel's value into the min pixel's value.

        Args:
            rasterfile: input original raster image, type can be filename(string,
            like "test1.tif"), rasterfile(class Raster) or numpy.ndarray.

        Returns:
            erosion_raster: raster image after erosion, type is numpy.ndarray.
        """
        if is_string(rasterfile):
            origin_raster = RasterUtilClass.read_raster(str(rasterfile))
        elif isinstance(rasterfile, Raster):
            origin_raster = rasterfile.data
        elif isinstance(rasterfile, numpy.ndarray):
            origin_raster = rasterfile
        else:
            return "Your rasterfile has a wrong type. Type must be string or " \
                   "numpy.array or class Raster in pygeoc."
        max_value_raster = origin_raster.max()
        erosion_raster = numpy.zeros((origin_raster.shape[0], origin_raster.shape[1]))
        # In order to compute the raster edges, we need to expand the original
        # raster's rows and cols. We need to add the edges whose pixels' value is
        # the max pixel's value in raster.
        add_row = numpy.full((1, origin_raster.shape[1]), max_value_raster)
        temp_origin_raster = numpy.vstack((numpy.vstack((add_row, origin_raster)), add_row))
        add_col = numpy.full((origin_raster.shape[0] + 2, 1), max_value_raster)
        expand_origin_raster = numpy.hstack((numpy.hstack((add_col, temp_origin_raster)), add_col))
        # Erode the raster.
        for i in range(origin_raster.shape[0]):
            for j in range(origin_raster.shape[1]):
                min_pixel_value = max_value_raster
                # Find the min pixel value in the 8-neighborhood.
                for k in range(3):
                    for l in range(3):
                        if expand_origin_raster[i + k, j + l] <= min_pixel_value:
                            min_pixel_value = expand_origin_raster[i + k, j + l]
                            # After this loop, we get the min pixel's value of the
                            # 8-neighborhood. Then we change the compute pixel's value into
                            # the min pixel's value.
                    erosion_raster[i, j] = min_pixel_value
        # Return the result.
        return erosion_raster
Erode the raster image.

         Find the min pixel's value in 8-neighborhood. Then change the compute
         pixel's value into the min pixel's value.

        Args:
            rasterfile: input original raster image, type can be filename(string,
            like "test1.tif"), rasterfile(class Raster) or numpy.ndarray.

        Returns:
            erosion_raster: raster image after erosion, type is numpy.ndarray.