I need to apply Sobel filter on image and detect the local maximum gradient for each edges direction. Pixels whole gradient are larger than threshold considered as edge pixel. Now the task is to find the width (pixel width) between the local maximum and local minimum for edge (edge pixels).