|
| 1 | +# ✏️ Pencil Sketcher |
| 2 | + |
| 3 | +A lightweight Python tool to turn your photos into beautiful pencil-style sketches using OpenCV. |
| 4 | +Ideal for creative projects, filters, image editors, or just for fun! |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 📸 Preview |
| 9 | + |
| 10 | +Original Image | Pencil Sketch |
| 11 | +:--:|:--: |
| 12 | + |  |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## 🚀 Features |
| 17 | + |
| 18 | +- Convert any image to a **pencil sketch** with a clean and elegant effect |
| 19 | +- Fast and lightweight — uses only OpenCV |
| 20 | +- Easily extendable for batch processing, GUI, or web apps |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## 🧠 How It Works |
| 25 | + |
| 26 | +1. Convert the image to **grayscale** |
| 27 | +2. Invert the grayscale image |
| 28 | +3. Apply a **Gaussian blur** |
| 29 | +4. Invert the blurred image |
| 30 | +5. Divide the grayscale image by the inverted blur to create the sketch effect |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## 🛠 Requirements |
| 35 | + |
| 36 | +- Python 3.6+ |
| 37 | +- OpenCV (`cv2`) |
| 38 | + |
| 39 | +Install with pip: |
| 40 | + |
| 41 | +```bash |
| 42 | +pip install opencv-python |
| 43 | +``` |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## 🧪 Usage |
| 48 | +Put your image in the same folder as the script and name it image.jpg |
| 49 | +Then run: |
| 50 | + |
| 51 | +python sketch.py |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## 🗂 Project Structure |
| 56 | + |
| 57 | +pencil-sketcher/ |
| 58 | +│ |
| 59 | +├── image.jpg # Input image |
| 60 | +├── sketch.py # Main Python script |
| 61 | +├── README.md # Documentation |
| 62 | +├── assets/ |
| 63 | +│ ├── original.jpg # Example original image (for preview) |
| 64 | +│ └── sketch.jpg # Example output sketch |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## 💡 Tips |
| 69 | +Works best with clear, high-resolution images |
| 70 | + |
| 71 | +You can adjust the blur size for sharper or softer effects: |
| 72 | + |
| 73 | +cv2.GaussianBlur(inverted, (21, 21), 0) |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## 📌 Future Ideas |
| 78 | +GUI with tkinter |
| 79 | + |
| 80 | +REST API with Flask or FastAPI |
| 81 | + |
| 82 | +Telegram bot for image sketching |
| 83 | + |
| 84 | +Web version with Streamlit |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## 👤 Author |
| 89 | +Made with 💙 by voidcompile |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## 📜 License |
| 94 | +MIT — Feel free to use, modify, and share! |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## 💻 voidcompile |
| 99 | +Stay updated with daily Python & AI projects on our channel: |
| 100 | + |
| 101 | +📢 [github: @voidcompile](https://github.com/voidcompile) |
| 102 | +📢 [Telegram: @voidcompile](https://t.me/voidcompile) |
| 103 | +📢 [youtube: @voidcompile](https://www.youtube.com/@voidcompile) |
| 104 | +📢 [email: voidcompile@gmail.com] |
0 commit comments