Git Product home page Git Product logo

hole-filling-small-library's Introduction

Hole Filling Small Library

Small image processing library that fills holes in images. The library supports Grayscale images, while the CMD Utility accepts two RGB images: an input image and another image which marks the hole mask.

input

Requirements

C++11

OpenCV 4.0.0

Usage:

HoleFilling >
HoleFilling > fill image-path mask-path z epsilon connectivity-type

Example:

HoleFilling > fill ../sample_images/cat.jpg ../sample_images/cat_mask.jpg 20 0.0001 4

Modules

  • image

    • pixel
      • Pixel : represents a pixel
      • PixelConnectivity : supports 4 and 8 connectivity
    • HoleFillingImage : abstract image with hole
    • GrayscaleImage : implements HoleFillingImage
  • utils

    • ImageUtil : utils reading, writing, float normalization, and converting images
  • weightfunction

    • WeightFunction : abstract weightfunction for two coordinates (pixels). In order to support arbitrary weightfunction as strategy
    • EucledianDistance : implements a WeightFunction
  • filler

    • FillingStrategy : abstract filling class to support various filling strategies.
    • DefaultFillingStrategy : implements a FillingStrategy
    • HoleFiller : a hole filler which works with HoleFillingImage, WeightFunction, and FillingStrategy
  • exception

    • EmptyImage : input image is empty
    • IllegalEpsilon : smaller or equals to 0
    • IllegalZ : smaller or equals to 0
    • IllegalPixelConnectivity : unimplemented connectivity
    • SizeMismatch : image and mask differ in size

Algorithm Complexity

In order to calculate the filling color for each hole pixel, we iterate all boundary pixels.

Consider the Boundary pixels set as B and denote |B| = n,

Consider the Hole pixels set as H and denote |H| = m,

Therefore, we get O(n x m)

Note that all areas of two-dimensional shapes are bounded by O(s^2) if s is the perimeter.

We can express the complexity as O(n ^ 3)

Approximate O(n) Algorithm Complexity

In order to acheive linear time, we need to estimate the interpolation for each hole pixel in constant time instead of running over all of the boundary pixels for each hole pixel. One way to acheive such approximation is to go over only connected boundary components in a circular manner.

First iteration is to calculate internal maximum boundary (inside the hole). For each, instead of iterating over all the boundary pixels, we iterate over its connected pixels to estimate the intensity. (Either 4 or 8) The next iteration woul be iterating the inner boundary of the previous while for each pixel we o the same. We continue in the described manner till we reach the centroid of the 2D hole.

hole-filling-small-library's People

Contributors

rabiaaqel avatar

Watchers

James Cloos 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.