Skip to content

SelimSavas/segment-anything-background-removal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Segment Anything Background Removal

I used Segment-Anything to remove background from photos. Doing this process is divided into two:

  • Foreground Detection and Segmentation
  • Non-foreground(background) Removal

Foreground Detection and Segmentation

  • Source Image : Image entered by the user
  • Bounding Box Image : User-entered bounding box
  • Segmented Image : Segmentation of the foreground image to be exempted from inference by segment anything

image

Background Removal

from PIL import Image

img = Image.fromarray(image_rgb)
mask = Image.open("/content/data/mask_2.png")
new_img = Image.new("RGBA", img.size, (0, 0, 0, 0))

for x in range(img.size[0]):
    for y in range(img.size[1]):
        if mask.getpixel((x,y)) == (255, 255, 255): # Beyaz piksel
            new_img.putpixel((x,y), img.getpixel((x,y)))
            
new_img.save("arkaplansiz_goruntu.png")

image

About

I used Segment-Anything to remove background from photos.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published