Giter Site home page Giter Site logo

focusdetection's Introduction

Focus Detection

Detects areas in focus in photos, by searching for sharpest areas and then enlarging them. Focus Detection works by converting the ouput of an high-pass filter to a mask.

To install

At the moment, the only dependencies are numpy and opencv. To install the package just do

pip install .

To run

Output is a file with same extension as the original file with a name suffix '_focus'

### run on a single image
python process.py -i input_image.jpg

### run on a directory of images
python process.py -i input_directory/ 

Parameters

The algorithm used for detection is still under development. At the moment there are two main free parameters:

  • high_pass_size sets the Gaussian Blur kernel size of the High Pass Filter (strength of the high-pass filter). Higher values lead to a more aggressive separation between in-focus and out-of-focus areas.

  • in_focus_regions sets how many countours the recursive median blur filter should stop, ie. how many disjoint in-focus areas we want to allow in the final mask. Values of 1 and 2 may lead to over-application of median blur recursively and shrinking of focus areas found.

Experiments on 20MP images suggest values of high_pass_size=12 and in_focus_regions=3.

Next Steps

  • Build an evaluation dataset, including images with different resolution
  • Train the algorithms by optimising the parameters.
  • Test different kernels for the initial step.

Inspiration

BurDetection2 by Will Brennan.

Demo

Focus Detection

focusdetection's People

Contributors

luismavs avatar

Stargazers

Shikai Li avatar  avatar  avatar  avatar David Ervideira 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.