anyway to save figure as uint8 format
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi: I want to make an animation with lots of figures. what I did is:
(1)write a for-loop to generate the .jpg file. (2) use writevideo to generate the animation based on the .jpg file.
the problem is that, if the number of .jpg files a huge, it cost lots of time to continuously read the .jpg file using function 'imread'
since the imread is to read the .jpg file into unit8 format, so I want know if there is anyway to save the figures as unit8 format, if I could save them into one structure file, I only have to read one time. it should make the animation created faster.
Thanks! Yu
7 Kommentare
Walter Roberson
am 26 Aug. 2018
filename = sprintf('%05d.bin', frame_number);
fid = fopen(filename, 'w'); %not 'wt' !!
fwrite(fid, YourArrayOfPixelData, '*uint8');
fclose(fid);
Image Analyst
am 26 Aug. 2018
Yu Li, you can make the video without the intermediate steps of creating a JPG file and then reading it back in you know. If you don't know how, then ask. Also, what format did you use to write the JPG files if it wasn't uint8? Also why are you using JPG as the format for the intermediate files rather than lossless PNG format?
Antworten (1)
Image Analyst
am 26 Aug. 2018
See my attached demo where I plot a surface in a graph, then make a movie out of that surface as it changes.
7 Kommentare
Walter Roberson
am 27 Aug. 2018
It takes a little work to render a contour plot to memory, but it is doable. If you use the syntax
[C,h] = contour(...) returns the contour matrix C containing the data that defines the contour lines, and the Contour object h.
and then you delete the contour object, then you would be left with C, the contour matrix. The contour matrix contains structured data that is a little bit of a nuisance to work with. Fortunately, Duane created https://www.mathworks.com/matlabcentral/fileexchange/38863-extract-contour-data-from-contour-matrix-c which extracts the data as line segments by coordinates.
With the line segments as coordinates in hand, you can use Vision System Toolbox insertShape to draw the lines into a matrix, and insertText() to add any labels you want. You can do this at arbitrary resolution.
You can then store the matrix in a 4D array indexed by the parfor loop index (row, col, color, frame number)
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!