On Friday, October 03, 2014 11:51:37 PM Jan Kybic wrote:
[snip]
> or better
>
> reinterpret(Uint8,convert(Array,separate(img)))
If you do Pkg.update(), then
reinterpret(Uint8, separate(img))
should work. If you think this needs to be documented, please add it to the
README (just click on the pencil icon when looking at README.md), but perhaps
this is discoverable enough that it doesn't need anything more than what is
already there.
> My second problem was that I tried to get the color dimension by
> "size(img,colordim(img))", in order to process each colour channel
> separately. This is actually taken from the documentation
> (https://github.com/timholy/Images.jl/blob/master/doc/core.md) but it
> no longer works, as "colordim(img)" returns 0.
This is exactly what should be happening: the new array is only 2-dimensional,
neither of which is used to encode color. After you call `reinterpret` or
`separate`, of course it will give a different answer (1 or 3, respectively).
> So what is the
> recommended way of finding out, whether the image is a color image or
> not?
The most general and efficient way is to use Julia's multiple dispatch: write
different versions of your algorithm for
function myfunction{CV<:ColorValue}(img::AbstractArray{CV}, ...)
and the fallback
function myfunction{T}(img::AbstractArray{T}, ...)
Alternatively, you can use `colorspace` or, on a separated image,
`ncolorelem`.
> Could you update the example in core.md, to show what is the
> generic way of processing the color channels one by one?
One of the advantages of representing as an RGB type is that, for most
algorithms, you no longer need to worry about this: you can process all 3
color channels at once, because operations are defined for RGB that allow you
to add, multiply, etc. But use reinterpret or separate if you still want/need
to do this.
> What I did for the moment was to convert it to Array as above and
> counting the number of dimensions but that is obviously not a robust
> solution.
colordim still works, when you need it and when you've separated the colors.
Hope this helps.
--Tim