AI Comic Panel Extractor
High-speed computer vision for mobile-optimized comic reading.
The AI Comic Panel Extractor is a specialized computer vision tool that automatically processes .cbz and .pdf files.
By detecting individual panel boundaries, it transforms static, hard-to-read pages into a panel-by-panel experience perfectly suited for mobile readers like CDisplayEx, Perfect Viewer, or Panels.

![]()
Core Engine Logic
The extraction engine uses OpenCV 4.9.0.80 to simulate human visual perception of a page layout.
The Process:
- Grayscale & Binarization: Strips color and applies Otsu thresholding. If the page is heavily yellowed or unevenly lit, it automatically falls back to Adaptive Gaussian thresholding to isolate ink from paper.
- Morphological Closing: Applies a scale-aware mathematical closing step to bridge small gaps in hand-drawn or faded panel borders without over-thickening lines.
- Contour Detection: Employs
cv2.findContours(usingRETR_EXTERNAL) to draw bounding boxes around outer panel regions, intentionally ignoring internal dialogue balloons. - Filtering & Sorting: Deduplicates overlapping boxes using IoU-based Non-Maximum Suppression (NMS) and dynamically sorts panels into a proper reading order based on median panel heights.
Deployment Options
The easiest way to run the tool locally. No background dependencies, environments, or installations required.
For developers or users with an existing Python environment. Run the application directly from source:
pip install PyMuPDF opencv-python==4.9.0.80 "numpy<2"
python desktop_app.pyDeploy the extractor as a browser-based application using React and FastAPI. You must start both servers simultaneously:
- Backend:
python backend/main.py - Frontend:
cd frontend && npm install && npm run dev
To avoid matrix calculation conflicts with NumPy 2.0, please ensure your Python environment uses the following exact versions:
- Python: 3.12.x
- OpenCV:
opencv-python==4.9.0.80 - NumPy:
numpy<2 - PyMuPDF: Latest stable
Testing & Archives
The bounding box algorithm is specifically tuned for the narrow gutters and ink-bleed typical of Golden Age and Silver Age comic scans. You can find excellent public domain material for testing at the following archives:
Technical Details & Known Limitations
How it works: The engine uses OpenCV to convert each page to grayscale and applies an Otsu/Adaptive binary threshold to isolate the ink. It then uses morphological closing to bridge gaps in panel borders, and contour detection (cv2.findContours) to draw candidate bounding boxes. Finally, it filters out noise based on aspect ratios, discards overlapping regions via IoU Non-Maximum Suppression (NMS), and calculates reading order using DPI-independent row clustering. See technical notes for further details.
Where it might fail (Please read): Because this relies on visual heuristics rather than publisher-provided metadata, it may not work in some cases. You may experience incorrect crops or missed panels under the following conditions:
- Overlapping Panels / Broken Gutters: If a character’s arm reaches outside a panel and breaks the gutter line, the algorithm may merge two panels together.
- Non-Rectangular / Splash Pages: Circular panels, extreme diagonals, or chaotic splash pages without clear borders will likely confuse the bounding box logic.
- Zero-Gutter / Full Bleed: If the page has no gutters at all (the art goes entirely to the edge of the page), the algorithm cannot slice it.
- Floating Text: Text or dialogue balloons that float in the absolute white space outside of a bordered panel may be ignored by the cropper.
Citation
@software{LocalComic-Panel-Extractor2026,
author = {Karim, ME.},
title = {AI Comic Panel Extractor},
year = {2026},
publisher = {GitHub},
url = {https://github.com/ehsanx/Comic-Panel-Extractor}
}This software is provided “AS IS”, without warranty of any kind. This tool is intended solely for use with files you legally own or those explicitly in the public domain. Please respect publisher copyrights.