Reputation: 2707
So far I have this:
using Images, Colors
a = Array{UInt8}(5, 5, 3)
imOutput = colorim(a)
How do I assign three values to a pixel:
imOutput[1,1] =
Upvotes: 0
Views: 462
Reputation: 2718
I think you meant (mind the dimensions for a
)
a = Array{UInt8}(3,5,5)
imOutput = colorim(a)
imOutput[1,1] = RGB(0,0,0)
imOutput
The tests for Images.jl helped me realize this.
Upvotes: 2
Reputation: 8566
i didn't know there is a data()
function, i actually find the solution by doing dump(imOutput)
:
Images.Image{FixedPointNumbers.UfixedBase{UInt8,8},3,Array{FixedPointNumbers.UfixedBase{UInt8,8},3}}
data: Array(FixedPointNumbers.UfixedBase{UInt8,8},(5,5,3)) 5x5x3 Array{FixedPointNumbers.UfixedBase{UInt8,8},3}:
[:, :, 1] =
0.314 0.498 0.337 0.0 0.102
0.584 0.0 0.549 0.565 0.498
0.337 0.0 0.102 0.212 0.0
0.549 0.816 0.498 0.906 0.0
0.102 0.584 0.0 0.545 0.188
[:, :, 2] =
0.588 0.0 0.0 0.0 0.0
0.337 0.0 0.0 0.0 0.0
0.549 0.0 0.0 0.0 0.0
0.102 0.0 0.0 0.0 0.0
0.498 0.0 0.0 0.0 0.0
[:, :, 3] =
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
properties: Dict{ASCIIString,Any} len 3
colorspace: ASCIIString "RGB"
colordim: Int64 3
spatialorder: Array(ASCIIString,(2,)) ASCIIString["y","x"]
the output shows that you can use imOutput.data
to access the data.
and yes, this is totally the same as data()
function, take a look at this line.
from the output, we can see imOutput
's colorspace is RGB
, so if we have a color from HSL
, we should convert that color into RGB
space before we pass that color into imOutput.data
. for example,
a = convert(RGB, HSL(270, 0.5, 0.5))
imOutput.data[1,1,:] = [a.r, a.g, a.b]
Upvotes: 1