Code Monkey home page Code Monkey logo

background-removal-tool's Introduction

background-removal-tool

This tool removes the background of an image based on manually added markers (based on OpenCV)

I wrote this small script as an answer to a StackOverflow question. However, I found myself using it quite often afterwards, thus I decided to make a repo so I can have easy access to it, and also make it available for other people that would like to use or shape it in their own application.

The script is based on OpenCV (cv2) library. The first step is to select several points/markers (pixel coordinates) to dictate the object you want to keep. This essentially means that this code, actually, keeps what you want from an image, and dumps the rest (rather than just removing the background). After you get the points, they are projected on an integer array of zeros to be used as a mask (the points should be a non-zero number [1, 255]). Then the watershed algorithm is used, taking the image and the mask as input. The resulting image is dilated by a small kernel (currently set to 3x3 pixels), to avoid losing information on the perimeter of the desired object. Finally, the dilated image is used as a mask to the original image (using the cv2.bitwise_and()). Then saves the image in a .png file with a preset name.

TODOs

Near future

  • Pass the image file/path as argument
  • Pass the markers as an argument
  • Pass the output filename as an argument
  • Utility to iterate over a dataset of similar images

Future

  • Create a GUI that allow the user to place the markers visually
  • Add function to the GUI for multiple images (can be exhausting for big datasets)
  • Add function to the GUI to place the markers on the mean image of an image dataset
  • Make it a proper tool and give it a proper name

background-removal-tool's People

Contributors

glrs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

background-removal-tool's Issues

Remove Background Tool

Hi, are you still working on remove background tools? I need a functioning server side script that removes backgrounds automatically from product image shots. Needs to work well with solid colors and gradients. Must remove extra artifacts such as text and/or logos, etc. Should not pixelate around humans bodies or clothing. Can pay $1000. needed for my app. Please let me know if you're interested. Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.