image.hsv2rgb
result = image.hsv2rgb(hsv)
Input: hsv · Output: result
What it is
hsv is a Record with h/s/v Mat fields, the shape image.rgb2hsv returns (a plain Image is refused by name, since it is the wrong shape — that is what rgb2hsv itself takes, not what it returns). Converts back to 8-bit RGB, rounding and clamping each channel to 0..255.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = image.hsv2rgb(hsv) | hsv Record, Mat, or Imagenot documented yet | result Image or Mat | Returns a new Image, same dimensions as the input Mats. Added in v0.4.0. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
import image
# A vertical edge: left half dark, right half bright.
m = zeros(4, 8)
for y in 0 to 3
for x in 4 to 7
m[y, x] = 255
end for
end for
img = image_from_matrix(m)
gx = image.sobel(img, direction="x")
gy = image.sobel(img, direction="y")
print(gx[0, 3], gx[0, 4]) # 1020 1020 -- the edge, straddled from both sides
print(gy[0, 3]) # 0 -- no variation along y at all
mag = image.gradient_magnitude(img)
print(mag[0, 3] == gx[0, 3]) # true -- gy is zero here, so magnitude reduces to |gx|
# A colorspace round trip: pure red is hue 0, full saturation, full value.
red = image_new(2, 2, r=255, g=0, b=0)
hsv = image.rgb2hsv(red)
print(hsv.h[0, 0], hsv.s[0, 0], hsv.v[0, 0]) # 0 1 1
back = image.hsv2rgb(hsv)
print(back.width, back.height) # 2 2
output
1020 1020 0 true 0 1 1 2 2
from images