Note that there are some explanatory texts on larger screens.

plurals
  1. POCompress movies of flat plots of few points and lines in Matlab (why are they so heavy?)
    primarykey
    data
    text
    <p>Consider a sequence of points:</p> <pre><code>N = 8 * 360; t = (0:9:N) + N / 4; x = sqrt(t) .* cos(t * pi / 180); y = sqrt(t) .* sin(t * pi / 180); </code></pre> <p>Then visualize the path, get the frames and make a movie:</p> <pre><code>f = figure('Position', [300 75 900 600]); hold on h_plot1 = plot(x(2:end), y(2:end), 'ob', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 5); h_plot2 = plot(x(1), y(1), 'o-r', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 5, 'LineWidth', 3); x_min = min(x); x_max = max(x); y_min = min(y); y_max = max(y); x_w = x_max - x_min; y_w = y_max - y_min; axis([x_min - x_w / 10 x_max + x_w / 10 y_min - y_w / 10 y_max + y_w / 10]) axis equal, axis off set(f, 'Color', [1 1 .25]) set(gca, 'Color', [1 1 .25]) set(gca,'nextplot','replacechildren'); vid = VideoWriter('myveryheavymovie.avi'); vid.Quality = 100; vid.FrameRate = 15; open(vid); for hh = 1:length(x)-1 hold on set(h_plot1, 'XData', x((hh + 1):end), 'YData', y((hh + 1):end)) set(h_plot2, 'XData', x(1:(hh + 1)), 'YData', y(1:(hh + 1))) tmp = plot(x(hh:hh+1), y(hh:hh+1), 'or', 'MarkerSize', 8, 'MarkerFaceColor', 'r'); writeVideo(vid, getframe(f)); delete(tmp) writeVideo(vid, getframe(f)); end close(vid); </code></pre> <p>The movie is <code>111,840 KB</code>, unreasonably heavy - is there a way to compress the movie? The images are just a handful of points and lines: can the movie be compressed to - say - less than <code>1,000 KB</code>?</p> <p><strong>EDIT</strong> following answers from A. Donda, chappjc and horchler</p> <p>Apparently I cannot change profile and for the moment I haven't tried third party software. I have tried generating a gif animation with imwrite:</p> <pre><code>% Consider a sequence of points: N = 8 * 360; t = (0:9:N) + N / 4; x = sqrt(t) .* cos(t * pi / 180); y = sqrt(t) .* sin(t * pi / 180); x_min = min(x); x_max = max(x); y_min = min(y); y_max = max(y); x_w = x_max - x_min; y_w = y_max - y_min; % Create figure: f = figure('Position', [300 75 900 600]); set(f, 'Color', [1 1 .25]) h_plot1 = plot(x(2:end), y(2:end), 'ob', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 3); hold on h_plot2 = plot(x(1), y(1), 'o-r', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 3, 'LineWidth', 3); axis([x_min - x_w / 10 x_max + x_w / 10 y_min - y_w / 10 y_max + y_w / 10]) axis equal, axis off set(gca, 'nextplot','replacechildren', 'Visible','off'); % preallocate mov fo gif animation nFrames = length(x)-1; frame = getframe(gca); [frame, map] = rgb2ind(frame.cdata, 256, 'nodither'); map = [map; 1 0 0]; mov = repmat(frame, [1 1 1 2*nFrames]); % Visualize it, get the frames and save gif animation for hh = 1:nFrames set(h_plot1, 'XData', x((hh + 1):end), 'YData', y((hh + 1):end)) set(h_plot2, 'XData', x(1:(hh + 1)), 'YData', y(1:(hh + 1))) hold on tmp = plot(x(hh:hh+1), y(hh:hh+1), 'or', 'MarkerSize', 8, 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r'); frame = getframe(gca); mov(:, :, 1, 2*hh-1) = rgb2ind(frame.cdata, map, 'nodither'); delete(tmp) frame = getframe(gca); mov(:, :, 1, 2*hh) = rgb2ind(frame.cdata, map, 'nodither'); end close(gcf) imwrite(mov, map, 'mynotsoheavygif.gif', 'DelayTime', 0, 'LoopCount', inf) </code></pre> <p>The gif file is <code>4,420 KB</code> - which is not good and not bad but better than the avi file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload