Skip to content
/ rbgg Public

Isolate and remove the background gradient from images of paper.

License

Notifications You must be signed in to change notification settings

fogleman/rbgg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Isolate and remove the background gradient from images of paper.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages