2015-08-14 23:31:26 +02:00
# Edgedetect
2015-08-15 01:03:50 +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.
2015-08-14 23:31:26 +02:00
2015-08-15 01:03:50 +02:00
**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.
2015-08-14 23:31:26 +02:00
## Installation
Add this line to your application's Gemfile:
```ruby
2015-08-15 01:03:50 +02:00
gem 'edgedetect', github: "timkaechele/edgedetect"
2015-08-14 23:31:26 +02:00
```
And then execute:
2015-08-15 01:03:50 +02:00
```sh
$ bundle
```
2015-08-14 23:31:26 +02:00
Or install it yourself as:
2015-08-15 01:03:50 +02:00
```sh
$ git clone git@github.com:timkaechele/edgedetect.git
$ cd edgedetect
$ rake install
```
2015-08-14 23:31:26 +02:00
## Usage
2015-08-15 01:03:50 +02:00
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.
2015-08-14 23:31:26 +02:00
2015-08-15 01:03:50 +02:00
```ruby
image = ChunkyPNG::Image.from_file("myfile.png")
2015-08-14 23:31:26 +02:00
2015-08-15 01:03:50 +02:00
naive = EdgeDetect::EdgeDetector.new(image)
sobel = EdgeDetect::SobelEdgeDetector.new(image)
2015-08-14 23:31:26 +02:00
2015-08-15 01:03:50 +02:00
naive.detect_edges # => ChunkyPNG::Image
sobel.detect_edges # => ChunkyPNG::Image
```
2015-08-14 23:31:26 +02:00
## Contributing
2015-08-15 01:05:13 +02:00
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 ](contributor-covenant.org ) code of conduct.
2015-08-14 23:31:26 +02:00
## License
The gem is available as open source under the terms of the [MIT License ](http://opensource.org/licenses/MIT ).