Skip to content

Commit

Permalink
enhance color contrast and black & white
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh committed Aug 13, 2024
1 parent d4de08f commit c0d0d4b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
**enhance color contrast**
<img src="ss4.png"/>

**enhance color contrast and black & white**
<img src="ss5.png"/>

## ⚙️Tech-Stack
- **Python**
- **OpenCV**
Expand Down
7 changes: 4 additions & 3 deletions preprocess_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def enhance_color_contrast(uploaded_image):
# Convert the image to grayscale
grayscale_image = final_pil_image.convert('L')

# Apply a binary threshold to convert the image to black and white
bw_image = grayscale_image.point(lambda x: 0 if x < 128 else 255, '1')
# Adjust the brightness of the grayscale image
brightness_enhancer = ImageEnhance.Brightness(grayscale_image)
brightened_image = brightness_enhancer.enhance(1.2)

return bw_image
return brightened_image
Binary file added ss5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c0d0d4b

Please sign in to comment.