You should have grasped the idea of how image erosion works on simple objects, and now we will continue with applying it to a real photo, separating a number plate's letters and digits from the rest of the content. Consider the following number plate:
The caribbean-2726429_640.jpg image is stored in the sample-images folder. We will first load the image, then create a binarized version, and then apply the erode function many times and compare the results, as follows:
using Images, ImageView, ImageMorphology
carplate_img = load("sample-images/caribbean-2726429_640.jpg")
carplate_img_binary = Gray.(Gray.(carplate_img) .< 0.5);
# converts black objects to white and vice-versa
carplate_img_binary_e = erode(carplate_img_binary)
imshow(carplate_img_binary)
carplate_img_binary_e = erode(erode(carplate_img_binary_e))
imshow(carplate_img_binary_e)
These are the results from eroding the image once and three times. No other text is left on the image, and the number plate is clear. Without any doubt, this can be used in text-recognition activities.
This is the first image:
This is the second image: