pencil_art is a Python package that converts images into pencil sketches using OpenCV. It provides a simple way to create a pencil sketch effect from a given image by applying image processing techniques such as grayscale conversion, Gaussian blurring, and inversion.
To install the pencil_art
package, use the following pip
command:
pip install pencil_art
from pencil_art import pencil_art
# Specify the input image path and output path for the pencil sketch
input_image = 'path_to_your_image.jpg'
output_image = 'output_sketch.jpg'
# Convert the image to a pencil sketch
pencil_art(input_image, output_image)
pencil_art(input_image_path, output_image_path)
input_image_path
(str): The path to the input image file that you want to convert to a pencil sketch.output_image_path
(str): The path where the resulting pencil sketch will be saved.
- This function does not return any value. The pencil sketch image will be saved to the specified output path.
input_image = 'sample_image.jpg'
output_image = 'sketched_output.jpg'
pencil_art(input_image, output_image)
This will read the image located at input_image
, convert it to a pencil sketch, and save it as output_image
.
The pencil_art
function performs the following steps to generate the pencil sketch effect:
- Grayscale Conversion: The input image is converted to grayscale to reduce color complexity.
- Gaussian Blurring: A Gaussian blur is applied to the grayscale image to smooth out details.
- Inversion: The blurred image is inverted.
- Sketch Creation: The pencil sketch effect is achieved by dividing the original grayscale image by the inverted blurred image.
The pencil_art
package requires the opencv-python
library. It is automatically installed when you install pencil_art
.
opencv-python
version 4.5.0 or later
If you'd like to contribute to the development of the pencil_art
package, feel free to fork the repository, make changes, and submit a pull request. We welcome improvements, bug fixes, and new features.
This package is licensed under the MIT License.