Compression of large figures in .fig format in MATLAB - matlab

My MATLAB script generates a figure from a timeseries data that, when saved, is over 200 MB in size. Is there a way to compress the figure to a lesser size in '*.fig' format? The compression has to be lossless so that I can zoom in and view the details in the figure. The figure has to be saved in *.fig format so that the axis property relations between subplots are preserved and I can use the data cursor tool.

The *.fig format cannot be saved as is in compressed form. The format is just not capable of it. But in MATLAB you can use functions zip to compress files created by savefig, and unzip with passing to openfig. This way you can create simple script to load and save zipped figs. Of course you will need to use a temp file, which should be taken care of as well.

Related

ILNumerics unable to read mat file of -v7 format

I know ILNumerics handles mat file saved using -v6 or -v7.3 option quite nicely but anyone knows how to make it recognize files saved using -v7 option?
The -v7 option by default uses compression and hence ILNumerics will give me a message saying it does not support compressed file and suggests me using -v6 option to save the file.
I guess nowdays mat file saved using latest releases of matlab (like 2010 - 2014) prefer the -v7 file format against the -v7.3 format which internally uses HDF5 because of the overhead HDF5 causeds. And since compression it's also smaller in size than the -v6 file which also is a big advantage.
So can ILNumerics fill this gap? Or is there already a solution that I missed?
Thanks.

ArcView (ArcGIS) AVL file format to Matlab mat file format

I have a file that is in AVL file format from a program called ArcGIS (formerly ArcView) that I need to convert to a mat file. It contains data I need to play back. Can anybody suggest a simple way to convert the file? I have done quite a bit of searching, and it seems the AVL is not a binary, aka it is a text format, which means I could write a program to convert it, but only if I also knew the corresponding matlab MAT file format. Moreover, this could take quite a while to do, and I need to file to be converted quickly so I can use the data.

Read and represent mp3 files using memmapfile in matlab

I have to analyze bio acoustic audiofiles using matlab. Eventually I want to be able to find anomalies in the audio. That's the reason I need to find a way to represent the audio in a way I can extract and compare features. I'm dealing with mp3 files up to 150 mb. These files are too large for matlab to read in to it's memory. Therefore I want to use the memmapfile() function. I used the following code and a small mp3 file to find out how it actually works.
[testR, ~] = audioread('test.mp3');
testM = memmapfile('test.mp3');
disp(testM.Data);
disp(testR);
The actual values of the testM.Data and testR are different. Audioread() returns a 7483391 x 2 matrix and memmapfile() a 4113874 x 1 matrix.
I'm not really sure how memmapfile() works, I expected this to be equal to each other. Is there a way to read mp3 files in the same format audioread() does using memmapfile()? And what does memmapfile actually return in case of an audio file? Maybe it's also usable in the vector format in the case of anomaly detection?
Thanks in advance!
NOTE: The original files were in wav IMA ADPCM format with sizes from 1.5 up to 2.5 gb. Since Matlab can't deal with that format and the size of the files I converted them to 8bit mp3 files.
I think that the problem is mammapfile by default read data in uint8 format, while audioread function read data in another way.
How you can see here you can specify the format of data when you read it with memmapfile, so try to "play" with different values. From the documentation I read that you can read data in double format, so try to modify the memmapfile data format and audioread data format.
Last thing, memmapfile always organize the data in matrix like "somenumbers x 1", so if you want the original one you need to use something like reshape.
Anyway if you work with big data I suggest you to try with something different instead memmapfile, because it is very very slow

How can I read a text file of image intensity values and convert to a cv::Mat?

I am working on a project that requires reading intensity values of several images from a text file that has 3 lines of file header, followed by each image. Each image consists of 15 lines of header followed by the intensity values that are arranged in 48 rows, where each row has 144 tab-delimited pixel values.
I have already created a .mat file to read these into Matlab and create a structure array for each image. I'd like to use OpenCV to track features in the image sequence.
Would it make more sense to create a .cpp file that will read the text file or use OpenCV and Matlab mex files in order to accomplish my goal?
I'd recommend writing C++ code to read the file directly independent of Matlab. This way, you don't have to mess with row major vs. column major ordering and all that jazz. Also, are there specs for the image format? If it turns out to be a reasonably common format, you may be able to find an off-the-self reader/library for it.
If you want the visualization and/or other image processing capabilities of Matlab, then mex file might be a reasonable approach.

Convert image to png byte array in Matlab

I would like to take a 512x512 image and convert it into a png byte array in Matlab so that I can stream it via a socket.
At the moment I take the array, write it to a png file using imwrite(I,'file.png'), then read it as a binary file and send it through the socket. This is obviously horribly inefficient because I first write to disk and then read from disk. I want to skip the and write to disk.
Is there anyway to do this in Matlab?
Probably not directly using the base MATLAB toolbox since the PNG file itself is created by the PNGWRITEC MEX-function. However, there may be some Java classes that can help, such as those in the javax.imageio package.