Read BMP file without image processing toolboxes

Dear,

due to some recent activities I was wondering if and how a bitmap image (RGB / .bmp ) could be loaded into Scilab without any external toolbox.

Also I wanted to avoid the need for openCV, Java, C or C++ wrapper.

I choose the bmp format, since it is very straight forward and relatively easy to understand.

In the end BMP files are “just” binary files, so it should be possible to load an bitmap image using mopen().

For anybody who might be interested in the subject, see the attached sci-file.

readBMPviaMopen.sci (3.1 KB)

Once the image data is stored as a variable in Scilab, it is possible to do all kind of things with it…e.g.: add transparency as an 4th channel.

Over the years I worked (and appreachiated) with various image processing toolboxes (IPD, SIVP, SIP, scicv, IPCV), so this post is meant to be an excursion in terms of “back to the roots”.

Best Regards,
Philipp

Hello Phiipp,

Thank you for this initiative. Can you improve your contribution by creating a standalone function, e.g. with protoype function mat=readbmp(path) and a documentation page (using the xml style of Scilab help pages) ? Then it would be possible to create a merge request in order to add your contribution in Scilab

S.

1 Like

Hello Stèphane,

thank you for the response.

It’s been a while since I was working on a Scilab toolbox, providing also help pages. Let me have a look, it may take a while, but: Yes, I can do that.

I was also thinking: If it is possible to use core Scilab functions to read a bitmap file, it should also be possible to use a similar approach for writing a bitmap

Following your suggestion it should be possible to do a function retVal = writebmp(path, mat) with retVal beeing a return value if the bitmap was successfully created or or not.

Philipp

1 Like

Hello philipp

In case you are interested I also write pure scilab code for reading and writing TIFF file image (very basic cases of the specifications). I can share the code with you if you want.