Sorry people, this is the right version: function imwrite{T <: FloatingPoint}(x::Array{T,2},fname) width, height = size(x) open(fname,"w") do stream write(stream, "P6\n$width $height\n255\n") for j in 1:height, i in 1:width, k = 1:3 write(stream,round(UInt8,255x[i,j])) end end end
Yakir Gagnon The Queensland Brain Institute (Building #79) The University of Queensland Brisbane QLD 4072 Australia cell +61 (0)424 393 332 work +61 (0)733 654 089 On Fri, Aug 7, 2015 at 7:26 PM, Yakir Gagnon <12.ya...@gmail.com> wrote: > In case this helps anyone, here’s a functioning barebone version: > > function imwrite{T <: FloatingPoint}(x::Array{T,2},fname) > height,width = size(x) > open(fname,"w") do stream > write(stream, "P6\n$width $height\n255\n") > for j in 1:width, i in 1:height, k = 1:3 > write(stream,round(UInt8,255x[i,j])) > end > end > end > > > > > Yakir Gagnon > The Queensland Brain Institute (Building #79) > The University of Queensland > Brisbane QLD 4072 > Australia > > cell +61 (0)424 393 332 > work +61 (0)733 654 089 > > On Fri, Aug 7, 2015 at 1:49 PM, Yakir Gagnon <12.ya...@gmail.com> wrote: > >> Thanks again Tim!!! >> >> I looked into your code and will try something like the following:julia >> write(stream, "P6\n") write(stream, "$width $height\n$mx\n") >> write(stream,img) >> where mx is the maximum value of the type used (e.g. 255 for UInt8). >> >> Cool about the splits, it makes sense (maybe more specific smaller parts >> of Images.jl will become more complex/functional/specialized). >> >> >> >> Yakir Gagnon >> The Queensland Brain Institute (Building #79) >> The University of Queensland >> Brisbane QLD 4072 >> Australia >> >> cell +61 (0)424 393 332 >> work +61 (0)733 654 089 >> >> On Fri, Aug 7, 2015 at 1:32 PM, Tim Holy <tim.h...@gmail.com> wrote: >> >>> `write`, although you'll have to encode the dimensions of the image if >>> you >>> want to be able to read it back in. >>> >>> FYI some of Images' functionality seems to be in the process of getting >>> split >>> out to smaller packages, see https://github.com/JuliaIO >>> >>> --Tim >>> >>> On Thursday, August 06, 2015 05:27:51 PM Yakir Gagnon wrote: >>> > I love and use Tim’s amazing Images.jl package. But, sometimes I >>> generate >>> > some data which results in an image. I then just want to save that >>> image to >>> > disk (or pipe it to imagemagick or something). I know I can include >>> Images >>> > and imwrite it to disk. But to load Images seems redundant just for one >>> > function, and when I use more than one processes (julia -p auto) it >>> really >>> > slows down the startup. >>> > >>> > Is there a simple (if ugly) way to save a 2D matrix of say UInt8 (or >>> any >>> > other sensible type) that included in Base? >>> > >>> > Thanks! >>> > >>> >>> >> >