The idea with this project is to try to detect speech bubbles on comics/mangas using Swift. Especially using Vision, Core Image and Core Graphics.
- Read the image
- Clean the image
- Detect contours
- Filter contours to discard unreasonable contours
- Use the contours bounds to clip the image and the contour poligon path to mask the invers of the speech bubble.
After that, the image should be ready for OCR
The image I will be using is a page of the manga ブラックジャックによろしく
For this step I'm applying multiple CIFilters. The speech bubbles should be really obvious after this step.
A VNDetectContoursRequest
seems to be doing a great job of detecting contours
Filter contours that have an area of at least 0.004, and no bigger than 0.4 and that have a proportion of area/perimeter of at least 0.02
With the contours identified, it's possible to crop and mask individual bubbles. To help on cleaning the bubble border, the path is stroked with white color.
TODO:
- It's possible that some contours inside contours aren't being checked.