Tim, does ImageCmap works with latest Julia? I cloned the latest Julia
repository (0.4), added the Color, Images, and ImageView package and run
this code (adapted from
https://groups.google.com/forum/#!searchin/julia-users/%22ImageCmap%22/julia-users/T-i1JdwB4zk/f7FEsh4En4oJ
but using PBM format in order not to rely on ImageMagick) with no avail.
using Images, Color
# build a sample image
datafloat = reshape(linspace(0.5, 1.5, 60000), 200, 300)
# convert the raw 0.5:1.5 data to a integer type, so we can index
dataint = iround(Uint8, 254*(datafloat - 0.5) + 1) # ranges from 1 to 255
# build our colormap
b = RGB(0,0,1)
w = RGB(1,1,1)
r = RGB(1,0,0)
cmaprgb = Array(RGB, 255)
f = linspace(0,1,128)
cmaprgb[1:128] = [(1-x)*b + x*w for x in f]
cmaprgb[129:end] = [(1-x)*w + x*r for x in f[2:end]]
img = ImageCmap(dataint, cmaprgb)
imwrite(img,"image.pbm")
The error is the following:
ERROR: MethodError: `mapinfo` has no method matching
mapinfo(::Type{Images.ImageMagick},
::Images.ImageCmap{Color.RGB{T<:Union{AbstractFloat,FixedPointNumbers.FixedPoint}},2,Array{UInt8,2}})
Closest candidates are:
mapinfo(::Type{Color.RGB{FixedPointNumbers.UfixedBase{UInt8,8}}}, ::Any)
mapinfo(::Type{Color.AlphaColorValue{Color.RGB{FixedPointNumbers.UfixedBase{UInt8,8}},FixedPointNumbers.UfixedBase{UInt8,8}}},
::Any)
mapinfo{CT<:Union{Color.AbstractAlphaColorValue{C<:Color.ColorValue{T},T<:Real},Color.ColorValue{T}}}(::Type{Color.RGB24},
::AbstractArray{CT<:Union{Color.AbstractAlphaColorValue{C<:Color.ColorValue{T},T<:Real},Color.ColorValue{T}},N})
...
in imwrite at /home/tomasi/.julia/v0.4/Images/src/io.jl:585
in anonymous at /home/tomasi/.julia/v0.4/Images/src/io.jl:576
in open at iostream.jl:114
in imwrite at /home/tomasi/.julia/v0.4/Images/src/io.jl:573
in imwrite at /home/tomasi/.julia/v0.4/Images/src/io.jl:186
Before submitting any bug report, I would like to be sure I'm not getting
something totally wrong.
Maurizio.
On Thursday, August 13, 2015 at 6:36:44 PM UTC+2, Tim Holy wrote:
>
> Images (on which ImageView is based) has an ImageCmap (= "image colormap")
> type. You could play with it and see how far you get.
>
> Also, see the "MapInfo" section of
> http://timholy.github.io/Images.jl/function_reference.html. It's a crazy-
> powerful mechanism for on-the-fly changes in how data are mapped to screen
> pixels.
>
> --Tim
>
> On Thursday, August 13, 2015 05:44:16 AM Maurizio Tomasi wrote:
> > Hi to everybody,
> >
> > I am the creator of Healpix.jl, a Julia
> > package (https://github.com/ziotom78/Healpix.jl) which implements
> > algorithms related to the Healpix sphere tessellation scheme
> > (http://healpix.jpl.nasa.gov/). The Healpix scheme subdivides a sphere
> in
> > patches (pixels) of equal area, and it is widely used in cosmology. I am
> > writing to julia-user because I would like to implement visualization
> > functions too, but I haven't figured out what is the best way to
> implement
> > them.
> >
> > So far, I have used the Healpy (https://github.com/healpy/healpy)
> library
> > as a reference for my implementation. Healpy wraps the original C++
> Healpix
> > library in a Python module. It uses Matplotlib to create plots of
> spherical
> > projections. Internally, both the original C++ Healpix library and
> Healpy
> > produce such plots by calculating a bitmapped representation of the
> > projection: they convert each (x,y) point in the image plane into a
> > normalized (u,v) coordinate, which is then spherically projected to a
> point
> > on the sphere's surface. The value associated to the point on the sphere
> > determines the color of the point at (x,y). Here are a few examples of
> > typical Healpix maps:
> http://healpix.jpl.nasa.gov/images/skymaps/ecl53s.gif
> > (Mollweide
> > projection), http://healpix.sourceforge.net/html/plot_orthpolrot.png
> > (Orthogonal projection).
> >
> > The algorithm is really easy to implement in Julia, but I cannot decide
> how
> > to actually do the following:
> >
> > 1. How to interactively show the map by e.g. opening a window, or by
> > displaying the image directly in a IJulia notebook?
> > 2. The bitmap produced using this algorithm associates a scalar to each
> > pixel, but one usually wants to convert such scalar through a color map
> in
> > order to have a RGB value to be actually drawable. (I am interested in
> > piecewise-linear maps).
> > 3. When displaying the map, how to put a color bar under the map, like
> in
> > the two links I provided above?
> >
> > I have had a look at ImageView, and it look ok for point 1. However, it
> > seems to me that it is oriented towards "real" image files, because I
> > cannot find support for color maps and color bars. If it is really so,
> is
> > there any other Julia package which would be relevant for my purposes?
> >
> > Thanks a lot,
> > Maurizio.
>
>