Git Product home page Git Product logo

aksenyuk / foreground-removal Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 26.15 MB

The project is based on the use of classical image processing methods to solve the problem of creating a clean plate. On the basis of a set of photos taken on an identical background, objects that move are removed in such a way as to obtain a photo containing only the background

HTML 50.90% Jupyter Notebook 49.10%
image-processing-python image-representation

foreground-removal's Introduction

Image Foreground Removal

Co-authored-by: @giminosk

Note: Download own_dataset manually from datasets folder, instead of using !wget as it is in the source code.

The algorithm performed:

  • Background/foreground segmentation by image comparison:

    1. Convert to grayscale
    2. Apply Gaussian Blur
    3. Repeat Step (1), (2) for the second image
    4. Calculate absolute difference between images obtained at previous steps
    5. Apply threshold to Step (4)
    6. Apply dilation to Step (5)
    7. Convert Step (6) to BGR to the final image with foreground removed
  • Collect background colors from the segmented image:

    1. Create mask for black color
    2. Apply this mask to the image
    3. Store the colors from the masked image to a list
    4. Remove black color from the resulting set of colors
  • Create "base" image to fill the foreground on:

    1. Combine masks obtained at Point (1) by merging it with the median of the initial image dataset
  • Calculate MLE (Maximum Likelihood (Neighborhood) Estimation):

    1. Calculate all the needed metrics:

      • Mean
      • Covarience
      • Inverse of Covarience
      • Probability of a pixel (difference between image pixels and mean calculated in Step (1))
      • Dot Product of probability matrix and inverted covarience matrix
      • Exponential of einsum of probability matrix and the result of the previous Step
    2. Store to a list MLE of each pixel of each image

  • Fill the foreground with pixels of probability higher than 0.15 threshold from the initial dataset images

  • Fill the remained foreground pixels with ones from the initial dataset images the colors of which are also in the set of background colors collected in Point (2)

  • Apply averaging of neighboring pixels to the rest of the pixels left blank

    (Note: Filling these pixels simply with the ones from the initial dataset images is also worth trying)

foreground-removal's People

Contributors

aksenyuk avatar

Watchers

 avatar

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.