Skip to content

Instantly share code, notes, and snippets.

View ziggystar's full-sized avatar

ziggystar

  • Bavaria, Germany
  • 09:52 (UTC +01:00)
View GitHub Profile
@witwall
witwall / deskew.java
Created May 12, 2013 22:27
Automatic image deskew in Java http://anydoby.com/jblog/en/java/1990 Those who have to process scans should know how painful it is to manually deskew images. There are several approaches to do this deskewing automatically. The basis of all the methods is to identify lines following the same direction in a image and then by deviation from horizon…
public double doIt(BufferedImage image) {
final double skewRadians;
BufferedImage black = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_BINARY);
final Graphics2D g = black.createGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
skewRadians = findSkew(black);
System.out.println(-57.295779513082320876798154814105 * skewRadians);
return skewRadians;
anonymous
anonymous / marginalize.cpp
Created December 14, 2012 17:40
(Hopefully) fast variable elimination algorithm.
#include <vector>
#include <set>
#include <iostream>
#include <functional>
#include <algorithm>
#include <assert.h>
using namespace std;
/** Computes the lookup table for a specific factor and a sequence of counting variables. */