Skip to content

Commit 8f56f4a

Browse files
authored
Merge pull request #643 from avats101/main
Added Rounded Image folder and updated Image Background Removal
2 parents 123bf19 + 2a6336c commit 8f56f4a

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

image_background_subtractor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ How to run the script?
2424

2525
$ python image_background_subtractor.py
2626

27-
Once done, the script will produce with the resultant image.
27+
Once done, the script will produce with the resultant image.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
opencv-python
22
numpy
3-
mediapipe
3+
mediapipe

image_rounded_corner/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
USER GUIDE
2+
Setup and activate virtual environment :
3+
4+
For Unix based systems please execute the following command to create venv and install requirements.
5+
6+
make init
7+
source .venv/bin/activate
8+
9+
Pre-requisites
10+
11+
1) Python pillow
12+
$ pip install pillow
13+
14+
How to run the script?
15+
16+
Please the edit the script with the source file location and the destination file location of the photo to be used.
17+
Run the python script
18+
19+
$ python rounded_corner.py
20+
21+
Once done, the script will produce with the resultant image.

image_rounded_corner/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pillow
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from PIL import Image, ImageDraw
2+
3+
4+
def add_corners(im, rad):
5+
circle = Image.new('L', (rad * 2, rad * 2), 0)
6+
draw = ImageDraw.Draw(circle)
7+
draw.ellipse((0, 0, rad * 2, rad * 2), fill=255)
8+
alpha = Image.new('L', im.size, 255)
9+
w, h = im.size
10+
alpha.paste(circle.crop((0, 0, rad, rad)), (0, 0))
11+
alpha.paste(circle.crop((0, rad, rad, rad * 2)), (0, h - rad))
12+
alpha.paste(circle.crop((rad, 0, rad * 2, rad)), (w - rad, 0))
13+
alpha.paste(circle.crop((rad, rad, rad * 2, rad * 2)), (w - rad, h - rad))
14+
im.putalpha(alpha)
15+
return im
16+
17+
18+
im = Image.open('Location_to_image/image.png')
19+
im = add_corners(im, 100)
20+
im.save('Location_to_store/img_rounded.png')

0 commit comments

Comments
 (0)