| Sabbir is a student of fourth year in CSE
    department. His course teacher recently gave him an assignment that is
    discussed below. But he is a little bit weak in programming. So, he needs
    your help to solve the problem.    Morphological
    image processing is a collection of non-linear operations related to the
    shape or morphology of features in an image. One of the most basic
    morphological operations is dilation. Dilation adds pixels to
    the boundaries of objects in an image. The number of pixels added to the
    objects in an image depends on the size and shape of the structuring
    element used to process the image. A structuring element is a
    shape mask used in the basic morphological operations. They can be of any
    shape and size that is digitally representable, and each has an origin. The
    matrix dimensions specify the size of the structuring element and the
    pattern of ones and zeros specifies the shape of the structuring
    element.  In this task the size of the structuring element is square
    i.e. 2×2, 3×3, or 4×4 etc. and can be of any shape. The
    morphological functions use the following code to get the coordinates of
    the origin of structuring elements of any size and dimension.  origin = floor(size(structuring_element)/2)   If
    structuring element matrix is [0 1 0; 1 1 1; 0 1 0]    Then, size(structuring_element)=
    3×3 So, origin = (1,1) [i.e.
    see the following figure]   Dilate (B,S) takes binary image B, places the origin
    of the structuring element S over each 1-pixel, and ORs the structuring
    element S into the output image at the corresponding position.   
   |