Class: Google::Cloud::Vision::Annotation::Properties::Color
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Annotation::Properties::Color
- Defined in:
- lib/google/cloud/vision/annotation/properties.rb
Overview
Color
Color information consisting of RGB channels, score, and fraction of image the color occupies in the image.
Instance Method Summary collapse
-
#alpha ⇒ Float
The amount this color that should be applied to the pixel.
-
#blue ⇒ Float
The amount of blue in the color.
-
#green ⇒ Float
The amount of green in the color.
- #inspect ⇒ Object
-
#pixel_fraction ⇒ Float
Stores the fraction of pixels the color occupies in the image.
-
#red ⇒ Float
The amount of red in the color.
- #rgb ⇒ Object
-
#score ⇒ Float
Image-specific score for this color.
-
#to_h ⇒ Hash
Converts object to a hash.
- #to_s ⇒ Object
Instance Method Details
#alpha ⇒ Float
The amount this color that should be applied to the pixel. A value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color.
163 164 165 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 163 def alpha @grpc.color.alpha || 1.0 end |
#blue ⇒ Float
The amount of blue in the color.
152 153 154 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 152 def blue @grpc.color.blue end |
#green ⇒ Float
The amount of green in the color.
143 144 145 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 143 def green @grpc.color.green end |
#inspect ⇒ Object
205 206 207 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 205 def inspect "#<Color #{self}>" end |
#pixel_fraction ⇒ Float
Stores the fraction of pixels the color occupies in the image.
187 188 189 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 187 def pixel_fraction @grpc.pixel_fraction end |
#red ⇒ Float
The amount of red in the color.
134 135 136 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 134 def red @grpc.color.red end |
#rgb ⇒ Object
167 168 169 170 171 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 167 def rgb red.to_i.to_s(16).rjust(2, "0") + green.to_i.to_s(16).rjust(2, "0") + blue.to_i.to_s(16).rjust(2, "0") end |
#score ⇒ Float
Image-specific score for this color.
178 179 180 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 178 def score @grpc.score end |
#to_h ⇒ Hash
Converts object to a hash. All keys will be symbolized.
196 197 198 199 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 196 def to_h { red: red, green: green, blue: blue, alpha: alpha, rgb: rgb, score: score, pixel_fraction: pixel_fraction } end |
#to_s ⇒ Object
201 202 203 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 201 def to_s "(colors: #{rgb})" end |