Armadillo is a linear algebra package; AFAIK does not provide graphical routines. If you use something like opencv for those, then it is really simple.
See this link for opencv imshow() and this link for how to use it in a program.
Note that opencv (like most other libraries) uses row indexing (x, y), and Armadillo uses column indexing (row, column), as described here .
For scaling it is most safe to convert to unsigned char yourself. In Armadillo, it will be something like:
`arma::Mat<unsigned char> mat2=255*(mat-mat.min())/(mat.max()-mat.min());`
Variables t and f are designed to set the axes; they are not part of the bitmap image.
You can use Armadillo for easy image writing. Here's a description of how to write handheld gray card (PGM) images and portable pixel cards (PPM). PGM export is only possible for 2D matrices, PPM export is only for 3D matrices, where the 3rd dimension (size 3) is the channels for red, green and blue.
The reason your Matlab shape looks prettier is because it has a color map: mapping each 0. 0.55 value to a vector [R, G, B], which determines the relative intensities of red, green, and blue. The photo has an RGB value at each point:
colormap(gray); x=imread('onion.png'); imagesc(x); size(x)
This is the 3rd dimension of the image.
Your matrix is a 2d image, so the most natural way to show it is with a gray level (as happened for your spectrum).
x=mean(x,3); imagesc(x);
This means that the intensities of R, G, and B increase together with the values in mat . You can put a color map of various combinations of R, G, B into a variable and use this instead, i.e. y=colormap('hot');colormap(y); . The y variable shows combinations of R, G, B for (scaled) image values.
You can also create your own color map (in Matlab you can specify 64 combinations of R, G and B with values from 0 to 1):
z[63:-1:0; 1:2:63 63:-2:0; 0:63]'/63 colormap(z);
Now, to increase the image values, the red intensities decrease (starting from the maximum level), the green intensity increases rapidly, and then decreases, and the blue values increase from minimum to maximum.
Since PPM appears (I don’t know the format) so as not to support color maps, you need to specify the values of R, G, B in a three-dimensional array. For a color order similar to z , you should make Cube<unsigned char> c(ysize, xsize, 3) , and then for each pixel y, x in mat2 , do:
c(y,x,0) = 255-mat2(y,x); c(y,x,1) = 255-abs(255-2*mat2(y,x)); x(y,x,2) = mat2(y,x)
or something very similar.