Binary matrix to image in octave

I have a 2D binary matrix and I would like to get a grayscale image from it. Someone suggested using imwrite but the problem is that instead of black and white the colors I get are black and red. The matrix contains only zeros and ones. Any idea why this is happening or how I could get the result I want. I'm running it on OS X. This is the line where I try to create the image.

imwrite(matrix, "image.bmp");


  • You have to convert your matrix to a boolean matrix.

    img = logical (matrix);
    imwrite (img, "image.bmp");