jnylen-colorscore 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/colorscore/histogram.rb +2 -2
- data/lib/colorscore/version.rb +1 -1
- data/test/histogram_test.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41850e99437a7328d6e7edc19576b2d1776077db
|
4
|
+
data.tar.gz: 828d20cbb163ed24b648c8cd0e85f49fffc9f0e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92c4e8f29715442f4899cb0cbb6913d3702f7a8374b3dd293227064d2c1b921259583600822dce56ec90ea21e8f016e9156b1eba1467afe83f85358c24654b0d
|
7
|
+
data.tar.gz: 6d4b95007e931d211f18d2855ccc25345e291acbe8302fc78312c7f69ff098d4ec4e3701f101390532060c004988909af4fea01c47210a375f20ef8472e96542
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
Major change from normal colorscore: .colors is .hex_colors.
|
2
|
+
|
1
3
|
# Colorscore
|
2
4
|
|
3
5
|
Colorscore is a simple library that uses ImageMagick to quantize an image and find its representative colors. It can also score those colors against a palette using the CIE2000 Delta E formula. This could be used to index images for a "search by color" feature.
|
@@ -19,4 +21,4 @@ histogram.scores.first # => [0.7884625, RGB [#7a9ab5]]
|
|
19
21
|
palette = Palette.from_hex(['ff0000', '00ff00', '0000ff'])
|
20
22
|
scores = palette.scores(histogram.scores, 1)
|
21
23
|
scores.first # => [0.16493763694876, RGB [#0000ff]]
|
22
|
-
```
|
24
|
+
```
|
data/lib/colorscore/histogram.rb
CHANGED
@@ -6,7 +6,7 @@ module Colorscore
|
|
6
6
|
params = [
|
7
7
|
'-resize 400x400',
|
8
8
|
'-format %c',
|
9
|
-
"-dither #{options.fetch(:dither) { 'None' }}"
|
9
|
+
"-dither #{options.fetch(:dither) { 'None' }}",
|
10
10
|
"-quantize #{options.fetch(:quantize) { 'YIQ' }}",
|
11
11
|
"-colors #{options.fetch(:colors) { 16 }.to_i}",
|
12
12
|
"-depth #{options.fetch(:depth) { 8 }.to_i}",
|
@@ -37,7 +37,7 @@ module Colorscore
|
|
37
37
|
def scores
|
38
38
|
total = color_counts.inject(:+).to_f
|
39
39
|
scores = color_counts.map { |count| count / total }
|
40
|
-
scores.zip(
|
40
|
+
scores.zip(hex_colors)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
data/lib/colorscore/version.rb
CHANGED
data/test/histogram_test.rb
CHANGED
@@ -3,12 +3,12 @@ require File.expand_path("../test_helper", __FILE__)
|
|
3
3
|
class HistogramTest < Test::Unit::TestCase
|
4
4
|
def test_color_count_is_correct
|
5
5
|
colors = 7
|
6
|
-
histogram = Histogram.new("test/fixtures/skydiver.jpg", colors)
|
7
|
-
assert_operator histogram.
|
6
|
+
histogram = Histogram.new("test/fixtures/skydiver.jpg", :colors => colors)
|
7
|
+
assert_operator histogram.hex_colors.size, :<=, colors
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_transparency_is_ignored
|
11
11
|
histogram = Histogram.new("test/fixtures/transparency.png")
|
12
|
-
assert_equal Color::RGB.from_html('0000ff'), histogram.
|
12
|
+
assert_equal Color::RGB.from_html('0000ff'), histogram.hex_colors.first
|
13
13
|
end
|
14
14
|
end
|