Mathematica Asked on February 12, 2021
Problem: I have printed some binary data from gdb which I’d like to inspect as an image. I am able to do this with gimp
if I parse the data as an RGBA raw image with width 251 and height 261. However, I’d like to use Wolfram to do this programatically.
I have tried
Import["/path/to/my/raw/image.bin", {"RawBitMap",
"Summary"}, ImageSize -> 251]
which almost works. The issue is that it parses as an RGB file (without an alpha channel), and so the image is totally corrupted.
Question: Is this possible in Wolfram?
This import format seems to be rather inflexible. The documentation, says,
Stores images as RGB or grayscale bitmaps at a resolution of 8 bits per channel.
Thus I would not bother with it.
Import as "Binary"
, use Partition
to put the data into the desired form, then use Image
to create the final image. I used something like this for a 150 by 150 image:
data =
ArrayReshape[
Import["~/Downloads/r.rbm", "Binary"],
{150, 150, 4}
];
Image[data, "Byte", ColorSpace -> "RGB"]
Correct answer by Szabolcs on February 12, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP