Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to save a matrix as an image in Julia in 2018

This is a trivial question, of course, but I'm having a hard time finding a working answer.

Given a matrix A ( either 2d for grayscale, or 3d for RGB) how to save it on the disk as an image file using Julia?

I have an old code written in 2016 when I would use

save("filename.png",Images.colorim(matrix_A))

Now this seems to be gone for good.

like image 690
Hayk Avatar asked May 26 '18 04:05

Hayk


1 Answers

you could use colorview to view your raw matrix as an image and then save it.

julia> using Images

julia> save("gray.png", colorview(Gray, rand(256,256)))

enter image description here

julia> save("rgb.png", colorview(RGB, rand(3,256,256)))

enter image description here

like image 144
Gnimuc Avatar answered Sep 19 '22 22:09

Gnimuc