Class: Thwomp::ColorCounter
- Inherits:
-
Struct
- Object
- Struct
- Thwomp::ColorCounter
- Defined in:
- lib/thwomp/color_counter.rb
Overview
Flattens all colors in given image file and calculates the diversity in used colors We can asume that if the image contains more than 2 colors, we have an interesting image
Constant Summary collapse
- FLATTEN_FACTOR =
4.0
Instance Attribute Summary collapse
-
#image_filename ⇒ Object
Returns the value of attribute image_filename.
Instance Method Summary collapse
-
#diversity ⇒ Object
returns the number of different colors.
-
#empty? ⇒ Boolean
tests if the image is empty.
-
#present? ⇒ Boolean
tests if the image contains an photo.
- #valid_png? ⇒ Boolean
Instance Attribute Details
#image_filename ⇒ Object
Returns the value of attribute image_filename
6 7 8 |
# File 'lib/thwomp/color_counter.rb', line 6 def image_filename @image_filename end |
Instance Method Details
#diversity ⇒ Object
returns the number of different colors
11 12 13 |
# File 'lib/thwomp/color_counter.rb', line 11 def diversity color_count.keys end |
#empty? ⇒ Boolean
tests if the image is empty
16 17 18 |
# File 'lib/thwomp/color_counter.rb', line 16 def empty? diversity.size < 2 end |
#present? ⇒ Boolean
tests if the image contains an photo
21 22 23 |
# File 'lib/thwomp/color_counter.rb', line 21 def present? !empty? end |
#valid_png? ⇒ Boolean
25 26 27 |
# File 'lib/thwomp/color_counter.rb', line 25 def valid_png? !!png end |