├── .ipynb_checkpoints └── Manga-checkpoint.ipynb ├── Manga.ipynb ├── README.md ├── main.py └── manga.jpg /README.md: -------------------------------------------------------------------------------- 1 | # Manga Frame Detect 2 | 3 | This is a simple Python program using OpenCV to detect frames in a Manga page. 4 | 5 | ## How to run 6 | 7 | Run the `main.py` with: 8 | 9 | ``` 10 | python main.py 11 | ``` 12 | 13 | ## Tutorial 14 | 15 | For more about the implementaion, please see [Main.ipynb](https://github.com/huytd/manga-frame-detect-opencv/blob/master/Manga.ipynb) the detailed tutorial. 16 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | from matplotlib import pyplot as plt 4 | 5 | filename = 'manga.jpg' 6 | 7 | orig = cv2.imread(filename) 8 | img = cv2.imread(filename) 9 | result = cv2.imread(filename) 10 | img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 11 | 12 | ret,thresh = cv2.threshold(img, 80, 255, cv2.THRESH_BINARY_INV) 13 | 14 | contours, h = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) 15 | 16 | for cnt in contours: 17 | hull = cv2.convexHull(cnt) 18 | cv2.drawContours(result, [cnt], -1, 255, -1) 19 | cv2.drawContours(result, [hull], -1, 255, -1) 20 | 21 | plt.subplot(121), plt.imshow(orig) 22 | plt.subplot(122), plt.imshow(result) 23 | plt.show() 24 | -------------------------------------------------------------------------------- /manga.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huytd/manga-frame-detect-opencv/8c0ea83b062bc6e3cf21042b2f8b7c5eec758e7e/manga.jpg --------------------------------------------------------------------------------