Questions
- Show with a binary image that morphological opening and closing are dual operations. (Hint: apply opening on an image foreground and closing on the image background with the same structuring element)
- Automatically crop an image using the convex hull of the object in it (the problem is taken from https://stackoverflow.com/questions/14211340/automatically-cropping-an-image-with-python-pil/51703287#51703287). Use the following image and crop the white background:
![](https://static.packt-cdn.com/products/9781789343731/graphics/4190e780-74ed-4f30-87b7-c5e370fe02ee.png)
The desired output image is shown as follows—the bounding rectangle to crop the image is to be found automatically:
![](https://static.packt-cdn.com/products/9781789343731/graphics/58b2af73-0f2a-4b9a-8003-f3f44f51e31a.png)
- Use the
maximum()
andminimum()
functions fromÂskimage.filters.rank
 to implement morphological opening and closing with a grayscale image.