I have a binary image in Matlab, and I need the binary array(0 and 1) in a C program,
How can I import it?
I can save the binary image in Matlab as “.mat” but I don’t know how to read the mat file in C.
Also I thought maybe I can save the binary image in Matlab as “.bin” which is readable in “C” but again I don’t know how to save an image in matlab as “.bin”.
Any help would be greatly appreciated.
You can also write your data to a binary file, which will be about twice smaller then text.
Then I believe you can read it in C without problems. Remember, MATLAB will write data by columns, not by rows – first 1st column, then 2nd, etc. If you want to read it in C by rows, just transpose the array before writing: