Git Product home page Git Product logo

rstreet85 / uncanny Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 4.0 29.19 MB

Java library to detect edges in images using the Canny algorithm with variable parameters.

Home Page: https://rstreet85.github.io/uncanny/

License: MIT License

Java 100.00%
canny-edge-detection canny edge-detection edge-detection-algorithm java maven travis-ci computer-vision image-processing digital-image-processing

uncanny's Introduction

Uncanny

License MIT Build Status

A pure Java implementation of John Canny's 1986 edge detector, including a Gaussian filter. The algorithm accepts an image, converts it to grayscale, blurs it with a Gaussian filter, and then detects the edges within it. It does so by finding the 'edge' magnitude of each pixel with a bi-directional Sobel operator, then disregarding all 'weak' edge pixels unless they are directly adjacent to a 'strong' edge pixel (hysteresis). The Canny is elegant - despite it's age and simplicity, it is still the standard for edge detection, and readily lends itself to optimization. This program is intended to provide quick method of detecting edges and study the Canny method, as well as getting quick feedback while tweaking parameters for specific projects.

Tester Class Usage

Command-line arguments: -fileName -outputFileExtension

Code Usage

//Sample JCanny usage
try {
    BufferedImage input = ImageIO.read(new File(imgFileName));
    BufferedImage output = JCanny.CannyEdges(input, CANNY_STD_DEV, CANNY_THRESHOLD_RATIO);
    ImageIO.write(output, imgExt, new File(imgOutFile));
} catch (Exception ex) {
    System.out.println("ERROR ACCESING IMAGE FILE:\n" + ex.getMessage());
}

Example:

test/test1.png png

Original Image Output Image

To-Do

  • Allow user to set the paramters for Gaussian filter & hysteresis for optimization purposes
  • Add Pratt figure of merit functionality, so that user can designate what edges they want, and determine how closely the output from parameters match.
  • Explore additional preprocessing methods, such as white balance.
  • Current edge image is smaller than original, add buffer to fix this

uncanny's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

uncanny's Issues

Test Image SIze

Christ on sale, why is the test image 54MB in size??!! New/smaller test image is required. The output of the operations is only ~300KB.

Tester Javadoc

The Javadoc for Tester.java looks sloppy, clean up pls.

Detected Edges: Offset from Image

Hello Robert!
Thanks for a nicely-structured implementation of the Canny algorithm.

I try to utilize your code to identify the borders of an A4 page pictured over a wooden table (picture is attached).

  • I use your hardcoded defaults for GAUSSIAN_RADIUS (7) and GAUSSIAN_INTENSITY (1.5).
  • I call the JCanny.CannyEdges method passing-in the parameters used in your test code (within Tester.java), i.e. numberDeviations=1 and fract=0.2.

The result image is attached. It includes the source-image, after being gray-scaled, and on top of it - the detected edge-points, in red.

You could see that (A4) page-borders are not appropriately marked.
The detected edges are shifted a bit in relation to page's actual location.

Could you please advise - how to fix this offset? It would be much appreciated.

Source:
portrait_blank_small

Result:
result

Result - Zoom:
result_cornerzoomed

Consolidate Gaussian

Currently, client class must call 1 of 2 methods exclusively: either grayscale or rgb. Modify class to provide single call to clients, then determine appropriate action.

GPL to MIT Conversion

Remove the old GPL headers from the individual classes and replace w/MIT header to reflect project license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.