edge_detect/README.md

82 lines
2.0 KiB
Markdown
Raw Normal View History

2015-08-14 23:31:26 +02:00
# Edgedetect
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
**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
gem 'edgedetect', github: "timkaechele/edgedetect"
2015-08-14 23:31:26 +02:00
```
And then execute:
```sh
$ bundle
```
2015-08-14 23:31:26 +02:00
Or install it yourself as:
```sh
$ git clone git@github.com:timkaechele/edgedetect.git
$ cd edgedetect
$ rake install
```
2015-08-14 23:31:26 +02:00
## Usage
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
```ruby
image = ChunkyPNG::Image.from_file("myfile.png")
2015-08-14 23:31:26 +02:00
naive = EdgeDetect::EdgeDetector.new(image)
sobel = EdgeDetect::SobelEdgeDetector.new(image)
2015-08-14 23:31:26 +02:00
naive.detect_edges # => ChunkyPNG::Image
sobel.detect_edges # => ChunkyPNG::Image
```
2015-08-14 23:31:26 +02:00
2015-08-15 01:11:03 +02:00
## Examples
Input file
2015-08-15 01:13:22 +02:00
![Airplane](test/pictures/airplane.png)
<br>
2015-08-15 01:11:03 +02:00
Naive Edge Detection
2015-08-15 01:13:22 +02:00
![Airplane with naive edge detection](test/output/airplane_standard.png)
<br>
2015-08-15 01:11:03 +02:00
Sobel Edge Detection
2015-08-15 01:13:22 +02:00
![Airplane with sobel edge detection](test/output/airplane_sobel.png)
2015-08-15 01:11:03 +02:00
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
2015-08-15 09:26:51 +02:00
The gem is available as open source under the terms of the GNU GPL v2.
2015-08-14 23:31:26 +02:00