Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fogleman/rbgg

Isolate and remove the background gradient from images of paper.
https://github.com/fogleman/rbgg

go golang image-processing

Last synced: 18 days ago
JSON representation

Isolate and remove the background gradient from images of paper.

Awesome Lists containing this project

README

        

# rbgg

Isolate and remove the background gradient from images of paper.

![Example](https://i.imgur.com/UorlQ7X.png)

![Steps](https://i.imgur.com/HePbtgy.jpg)

### Motivation

One of my hobbies is using a pen plotter to make [computer-generated drawings](https://www.michaelfogleman.com/plotter/).
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](https://i.imgur.com/D6u4dx3.jpg)