Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/fogleman/rbgg
- Owner: fogleman
- License: mit
- Created: 2018-03-02T20:38:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-25T20:38:18.000Z (over 6 years ago)
- Last Synced: 2024-08-01T00:43:13.879Z (3 months ago)
- Topics: go, golang, image-processing
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 353
- Watchers: 7
- Forks: 18
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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)