• Stars
    star
    583
  • Rank 76,663 (Top 2 %)
  • Language
    Haskell
  • License
    GNU Affero Genera...
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Scriptable desktop app to correct the perspective of images

Icon Perspec

App and workflow to perspectively correct images. For example whiteboards, document scans, or facades.

App Workflow

Step Description Result
1 Take photos Original image
2 Open Perspec app Opened Perspec App
3 Drop the images onto the window Dropped image
4 Mark the corners by clicking on them Marked corners
5 Click one of the save buttons (or [Enter]) Corrected image

Installation

WARNING: Perspec currently only works on macOS and Linux. Any help to make it work on Microsoft (Ticket) would be greatly appreciated!

Prebuilt

You can get this (and previous) versions from the releases page.

The current nightly version can be downloaded from https://github.com/feramhq/Perspec/actions. However, it's necessary to fix the file permissions after download:

chmod +x \
  ./Perspec.app/Contents/MacOS/Perspec \
  ./Perspec.app/Contents/Resources/{perspec,script,imagemagick/bin/convert}

On macOS you can also install it via this Homebrew tap:

brew install --cask ad-si/tap/perspec

From Source

Build it from source with Haskell's stack.

Platypus, with command line tools enabled , is required to build from source.

git clone https://github.com/feramhq/Perspec
cd Perspec
make install

This copies the Perspec.app to your /Applications directory and makes the perspec command available on your path. You can then either drop images on the app window, or use it via the CLI like perspec fix image.jpeg

Usage via CLI

It's also possible to directly invoke Perspec via the CLI like so:

/Applications/Perspec.app/Contents/Resources/perspec fix path/to/image.jpeg

You can also pass several images and they will all be opened one after another. This is very useful for batch correcting a large set of images.

Photo Digitization Workflow

  1. Take photos
    1. Use camera app which lets you lock rotation (e.g. OpenCamera). Otherwise check out the guide below to fix rotation.
    2. Use a sound activated camera to take photos simply by clicking your tongue or snipping your finger. E.g. with:
  2. Use perspec rename sub-command to fix order and names of scanned files.
  3. Verify that
    • All pages were captured and have the correct filename
    • Images are sharp enough
    • Images have a high contrast
    • Images have correct orientation
  4. For best image quality convert images optionally to a lossless format (e.g. png), apply rotations, and convert them to grayscale. Attention: Exclude the covers!
    mogrify -verbose -format png \
      -auto-orient -colorspace gray photos/*.jpeg
  5. Use Perspec to crop images
    perspec fix photos/*.png

Additional Steps

Improve colors with one of the following steps:

  1. Normalize dynamic range:
mogrify -verbose -normalize photos/*.png
  1. Convert to black and white:
    #! /usr/bin/env bash
    
    find . -iname "*.png" | \
    while read -r file
    do
      convert \
        -verbose \
        "$file" \
        \( +clone -blur 0x60 -brightness-contrast 40 \) \
        -compose minus \
        -composite \
        -negate \
        -auto-threshold otsu \
        "$(basename "$file" ".png")"-fixed.png
    done

In order to rotate all photos to portrait mode you can use either

mogrify -verbose -auto-orient -rotate "90>" photos/*.jpeg

or

mogrify -verbose -auto-orient -rotate "-90>" photos/*.jpeg

Features

  • Rescale image on viewport change
  • Handle JPEG rotation
  • Draw lines between corners to simplify guessing of clipped corners
  • Bundle Imagemagick
  • Better error if wrong file format is dropped (images/error-message.jpg)
  • Center Perspec window on screen
  • Drag'n'Drop for corner markers
  • "Submit" button
  • "Convert to Grayscale" button
  • Add support for custom output size (e.g. A4)
  • Manual rotation buttons
  • Zoom view for corners
  • Label corner markers

Algorithms

Perspective Transformation

Once the corners are marked, the correction is equivalent to:

convert \
  images/example.jpg \
  -distort Perspective \
    '8,35 0,0 27,73 0,66 90,72 63,66 67,10 63,0' \
  -crop 63x66+0+0 \
  images/example-fixed.jpg

Grayscale Conversion

Converts image to grayscale and normalizes the range of values afterwards. (Uses Imagemagick's -colorspace gray -normalize)

BW Conversion

Converts image to binary format with OTSU's method. (Uses Imagemagick's -auto-threshold OTSU -monochrome)

Interpolation of Missing Parts

Perspec automatically interpolates missing parts by using the closest pixel. (https://www.imagemagick.org/Usage/misc/#edge)

Technologies

Related

Check out ad-si/awesome-scanning for an extensive list of related projects.

More Repositories

1

awesome-music-production

A curated list of software, services, and resources to create and distribute music
978
star
2

awesome-sheet-music

A curated list of awesome sheet music software, libraries and resources.
753
star
3

Transity

Keep track of your ๐Ÿ’ต, ๐Ÿ•˜, ๐Ÿ–, ๐Ÿ„, ๐Ÿป on your command line with the plain text accounting tool of the future! ๐Ÿš€
PureScript
617
star
4

awesome-3d-printing

A curated list of awesome 3D printing resources
520
star
5

Rust-Flashcards

Over 550 flashcards to learn Rust from first principles. Written in markdown with script to convert them to an Anki deck or PDF file.
Rust
515
star
6

awesome-scanning

A curated list of awesome projects to simplify and improve paper and document scanning.
371
star
7

awesome-lego

Curated list of awesome LEGO resources
286
star
8

tu

CLI tool to convert a natural language date/time string to UTC
Rust
225
star
9

TaskLite

The CLI task manager for power users
Haskell
204
star
10

RosettaGit

Solutions to tasks in over 700 programming languages
HTML
196
star
11

invoice-maker

Generate beautiful invoices from simple Typst or YAML data records
Typst
116
star
12

awesome-soundfonts

A curated list of awesome soundfont software, libraries, and resources.
89
star
13

shaven

DOM building utility & Template engine based on JsonML + syntax sugar
JavaScript
69
star
14

vectual

Open source charting library written in Elm
Elm
68
star
15

awesome-laser-cutting

A curated list of awesome laser cutting resources.
63
star
16

Textalyzer

Analyze key metrics like number of words, readability, complexity, etc. of any kind of text
Rust
55
star
17

cai

The fastest CLI tool for prompting LLMs. Including support for prompting several LLMs at once!
Rust
45
star
18

awesome-e-commerce

A curated list of awesome e-commerce resources
36
star
19

nix-companies

Curated list of companies that use Nix / NixOS in production
35
star
20

DOMinate

DEPRECATED. Use https://github.com/ad-si/shaven instead
JavaScript
35
star
21

awesome-fabrication

A curated list of awesome fabrication software, tools and resources.
28
star
22

ulid

Haskell implementation of ULIDs (Unique Lexicographically Sortable Identifiers)
Haskell
24
star
23

lilynode

JavaScript wrapper for LilyPond
TypeScript
23
star
24

bitcoinate

Integrate the bitcoinate button and get supported!
JavaScript
23
star
25

scikit-image-cheatsheet

See all scikit-image methods for image creation & manipulation and their output at a glance.
HTML
21
star
26

life-is-short

Just a little reminder of how much time of your life you've already wasted ๐Ÿ˜‰
JavaScript
19
star
27

fakesome

The fake data generator
JavaScript
15
star
28

meshlib

JavaScript library for processing mesh-based 3D models
CoffeeScript
13
star
29

CityViz

Interactive real time WebGL powered 3d rendering of CityGML files
JavaScript
12
star
30

GeneralUser

Friendly fork of the GeneralUser GS soundfont. (FluidSynth version)
TeX
12
star
31

polyphone

Mirror of the soundfont editor "polyphone"
C
10
star
32

textnet

The Internet of Text
JavaScript
10
star
33

dotfiles

My precious dotfiles
Shell
10
star
34

nodeslicer

Wrapper for PrusaSlicer
TypeScript
10
star
35

uku

Display Ukulele fingering charts in the terminal
Haskell
9
star
36

brickify

Speed up 3D printing using LEGOยฎ bricks
CoffeeScript
9
star
37

ybdb

YAML Based Database
JavaScript
8
star
38

nodescad

Node.js wrapper for OpenSCAD
JavaScript
8
star
39

adriansieber-com

My website & blog with articles about tech, the command line, Haskell, โ€ฆ
Jupyter Notebook
8
star
40

stl-parser

Transform STL into json streams
TypeScript
7
star
41

epub-metadata

Reads metadata from an epub file
JavaScript
7
star
42

lamda

A browser based desktop environment including several default apps. All data is stored in plain text files for maximum data sovereignty and hackability.
JavaScript
7
star
43

fluidnode

Node.js bindings for the FluidSynth software synthesizer.
TypeScript
7
star
44

yaml2json

A stream transformer to convert YAML to JSON
JavaScript
6
star
45

climar

Command line image renderer with a focus on pixel-precise rendering of small images / icons / graphics.
JavaScript
6
star
46

lilyware

Middleware for serving rendered lilypond files
JavaScript
6
star
47

csvnorm

Command line tool to normalize CSV, TSV, and other *SV files
TypeScript
6
star
48

gray-code-disc-generator

Create SVG gray-code discs with an adjustable number of tracks
TypeScript
6
star
49

waity

Loading Spinner Generator
JavaScript
6
star
50

svgscript

Tooling and workflows for generating SVGs with JavaScript modules
JavaScript
6
star
51

stl-models

Collection of various STL models for testing purposes. Includes a JavaScript SDK for simplified loading.
CoffeeScript
6
star
52

mardow

The Ultimate Markdown Viewer
JavaScript
5
star
53

eventlang

EventLang is a human readable event/logging language. Also sable as a delta encoding for YAML files.
JavaScript
5
star
54

kinect-mount

Laser cut Kinect mount for tripods. Moved to ad-si/physibles.
5
star
55

awesome-pencil

A curated list of awesome resources for the protoptyping app Pencil
5
star
56

svgtalk

SVG generator implemented in GNU Smalltalk
Smalltalk
5
star
57

FeetJ

Touch floor MIDI controller for DAWs that is controlled with your feet
C
5
star
58

htk

Graphical User Interfaces for Haskell Programs (Mirror)
Haskell
5
star
59

awesome-command-line-tools

Curated list of awesome CLI tools
5
star
60

physibles

Collection of various physibles (e.g. catapult, boat, propeller, chess set, GorillaPod mount, glasses)
OpenSCAD
5
star
61

yaml-diff-patch

Diffing and patching for YAML documents.
JavaScript
4
star
62

file-formats

List of all file formats and one example file for each format.
JavaScript
4
star
63

docker-ledger-web

Dockerfile for node-ledger-web
Dockerfile
4
star
64

awesome-electronics

Curated list of awesome electronics tools, libraries, and knowledge
4
star
65

fingerfury

An adaptive touch typing game
JavaScript
4
star
66

biocrypt

Secure biometric identification for the masses
JavaScript
4
star
67

stl-exporter

Export array based representations of 3D models (as used by http://github.com/brickify/meshlib) to binary and ascii-STLs
CoffeeScript
4
star
68

csstab

A lookup table for CSS properties and selectors
JavaScript
4
star
69

image-resize-middleware

Image resizing middleware
JavaScript
4
star
70

awesome-video-production

A curated list of software, services, and resources to create videos
4
star
71

awesome-ray-tracing

Curated list of awesome ray-tracing resources
4
star
72

three-convert

Convert JSON-based 3D model representations to three.js geometries and vice versa
CoffeeScript
4
star
73

Polyblocks

Multiplayer Tetris game
JavaScript
4
star
74

html2shaven

Convert HTML documents to shaven arrays
JavaScript
3
star
75

end-of-week

Get the last day of a week (Sunday) according to UTC
JavaScript
3
star
76

ergoa

ErgoA keyboard layout for the ErgoDox EZ and ErgoTravel keyboard
C
3
star
77

purescript-result

Computations that may succeed or fail.
PureScript
3
star
78

tabledown

Easily create Markdown and ASCII tables in JavaScript. Including CLI tool to pretty print JSON as tables.
JavaScript
3
star
79

iReplica

The perfect replica of the iDevices
3
star
80

timeify

ISO 8601 based time module with support for dates, times, durations and time intervals.
JavaScript
3
star
81

table-convert

Convert complex HTML tables to Multimarkdown and LaTeX tables
TypeScript
3
star
82

muscii

Render sheet music as ASCII art in your terminal
3
star
83

regm

An online register machine
JavaScript
3
star
84

failarchive

Extensive archive of fail videos
JavaScript
3
star
85

awesome-3d-models

A curated list of awesome 3D models
3
star
86

gitcdn

GitCDN - The GitHub driven Content Delivery Network
JavaScript
3
star
87

Perspectra

Automatically extract documents from images and perspectively correct them with classic computer-vision algorithms
Python
3
star
88

subf

Substitue all occurences of strings with their replacements. Substitution pairs are read from a TSV file.
JavaScript
3
star
89

streamtester

A writable stream which can perform specified tests on the written data
JavaScript
3
star
90

cubix

The Mechanical Display
JavaScript
3
star
91

mapkeys

Copy and remap / rename keys to a new object
JavaScript
3
star
92

purescript-typedtime

Data types to specify datetimes at compile time
PureScript
3
star
93

utcify

Website to convert any datetime string to UTC
HTML
3
star
94

UpdateYourBrowser

Remind your visitors to update their browser to the latest version.
JavaScript
2
star
95

bitcoinate.org

Official bitcoinate website
HTML
2
star
96

homebrew-browsers

Casks for old browser versions
Ruby
2
star
97

buffer-converter

Convert node Buffers to ArrayBuffers and vice versa
CoffeeScript
2
star
98

alterm

Find alternatives to apps, websites and programs right in your terminal!
JavaScript
2
star
99

sif

2
star
100

rad2deg

Convert radians to degree
JavaScript
2
star