rbgg

command module
v0.0.0-...-f47f8dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2018 License: MIT Imports: 9 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL