필터 지우기
필터 지우기

anyway to save figure as uint8 format

조회 수: 6 (최근 30일)
Yu Li
Yu Li 2018년 8월 25일
댓글: Walter Roberson 2018년 8월 27일
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
Walter Roberson
Walter Roberson 2018년 8월 26일
filename = sprintf('%05d.bin', frame_number);
fid = fopen(filename, 'w'); %not 'wt' !!
fwrite(fid, YourArrayOfPixelData, '*uint8');
fclose(fid);
Image Analyst
Image Analyst 2018년 8월 26일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2018년 8월 26일
See my attached demo where I plot a surface in a graph, then make a movie out of that surface as it changes.
  댓글 수: 7
Yu Li
Yu Li 2018년 8월 27일
contour plot
Walter Roberson
Walter Roberson 2018년 8월 27일
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)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by