Giter VIP home page Giter VIP logo

rbgg's Introduction

rbgg

Isolate and remove the background gradient from images of paper.

Example

Steps

Motivation

One of my hobbies is using a pen plotter to make computer-generated drawings. I often take pictures of these drawings to post online, but it's hard to get even, consistent lighting across the entire photo. Instead of trying to perfect the lighting, I wrote this software to clean up the images for me.

Installation

$ go get -u github.com/fogleman/rbgg

Usage

$ rbgg input.jpg

How it Works

For every pixel in the image, we analyze its neighborhood (a box centered on the pixel, with size 5% x 5% of the image size by default) to determine the paper intensity in that region. The 90th percentile brightness is selected by default. The pixel is rescaled to bring this window brightness up to the target brightness. This algorithm will have trouble if certain regions are mostly ink (rather than mostly paper) and can still leave some "vignetting" at the corners of the image. Analyzing a 5% x 5% region around every pixel naively would be very slow - so the code uses some tricks to do this more efficiently.

Another Example

Works well for notes and maybe whiteboards too. Obviously software for this purpose already exists but sometimes you just gotta write your own tools so you can fine tune them for your own needs!

Example

rbgg's People

Contributors

fogleman 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.