Go to file
2020-08-24 08:08:30 +02:00
lib refactored the nearby method into it's own module 2020-08-24 08:08:30 +02:00
test Update edge_detector_test.rb 2020-08-24 08:08:30 +02:00
.gitignore added some examples 2020-08-24 08:08:30 +02:00
CODE_OF_CONDUCT.md added basic concepts 2015-08-14 23:31:26 +02:00
edgedetect.gemspec added a better readme and fixed the gemspec 2020-08-24 08:08:30 +02:00
Gemfile added basic concepts 2015-08-14 23:31:26 +02:00
LICENSE.txt added basic concepts 2015-08-14 23:31:26 +02:00
Rakefile added basic concepts 2015-08-14 23:31:26 +02:00
README.md added all the documentation 2020-08-24 08:08:30 +02:00


EdgeDetect is a pure ruby implementation of an edge detect algorithm. It is by no means fast enough to be considered useful in a real world application, it is just a proof of concept. It is build around the ChunkyPNG gem and therefore can only work with PNG files.

Warning: Because I find it hard to test a purely subjective experience of a good edge detection, I didn't write tests in the normal way. If you run the tests some basic math stuff will be tested, but the final edge detection is not tested, instead you can view the results in the test/output folder.


Add this line to your application's Gemfile:

gem 'edgedetect', github: "timkaechele/edgedetect"

And then execute:

$ bundle

Or install it yourself as:

$ git clone git@github.com:timkaechele/edgedetect.git
$ cd edgedetect
$ rake install


There are two basic EdgeDetect implementations, one that naively builds the difference between the gray value of each individual pixel and one more advanced but also slower one, that uses the sobel operation to detect the edges. Both can be used in the same way.

image = ChunkyPNG::Image.from_file("myfile.png")

naive = EdgeDetect::EdgeDetector.new(image)
sobel = EdgeDetect::SobelEdgeDetector.new(image)

naive.detect_edges # => ChunkyPNG::Image
sobel.detect_edges # => ChunkyPNG::Image


Input file


Naive Edge Detection

Airplane with naive edge detection

Sobel Edge Detection

Airplane with sobel edge detection


Bug reports and pull requests are welcome on GitHub at https://github.com/timkaechele/edgedetect. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the GNU GPL v2.