Grayscale morphology processing matlab code