Skip to content

Commit

Permalink
video with paddings
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloyeo committed Jul 1, 2024
1 parent 3b79b3e commit 8259320
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 6 deletions.
Binary file modified pics/2024-06-28-Affine_Transformation/2d_permutation.mp4
Binary file not shown.
Binary file modified pics/2024-06-28-Affine_Transformation/2d_rotation.mp4
Binary file not shown.
Binary file modified pics/2024-06-28-Affine_Transformation/2d_shear.mp4
Binary file not shown.
Binary file modified pics/2024-06-28-Affine_Transformation/3d_reflection.mp4
Binary file not shown.
Binary file modified pics/2024-06-28-Affine_Transformation/3d_rotation.mp4
Binary file not shown.
Binary file modified pics/2024-06-28-Affine_Transformation/3d_shear.mp4
Binary file not shown.
65 changes: 59 additions & 6 deletions pics/2024-06-28-Affine_Transformation/pics.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
h = zeros(1, numel(X));

v = VideoWriter('vector2dot.mp4', 'MPEG-4');
v.FrameRate = 30; % 프레임 속도 설정 (초당 프레임 수)
v.FrameRate = 60; % 프레임 속도 설정 (초당 프레임 수)
v.Quality = 100;
open(v);

for idx = 1:numel(X)
h(idx) = arrow([0, 0], [X(idx), Y(idx)], 'color', cmap(idx,:), 'linewidth', 1, 'EdgeColor', 'k');
drawnow;
frame = getframe(gcf);
if mod(size(frame.cdata, 1), 2) ~= 0
frame.cdata(end+1, :, :) = uint8(ones(1, size(frame.cdata, 2), 3) * 255);
end

if mod(size(frame.cdata, 2), 2) ~= 0
frame.cdata(:, end+1, :) = uint8(ones(size(frame.cdata, 1), 1, 3) * 255);
end
writeVideo(v, frame);
end

Expand All @@ -29,11 +37,26 @@
drawnow;

frame = getframe(gcf);
if mod(size(frame.cdata, 1), 2) ~= 0
frame.cdata(end+1, :, :) = uint8(ones(1, size(frame.cdata, 2), 3) * 255);
end

if mod(size(frame.cdata, 2), 2) ~= 0
frame.cdata(:, end+1, :) = uint8(ones(size(frame.cdata, 1), 1, 3) * 255);
end
writeVideo(v, frame);
end

for i = 1:30 % dummy frame at the end
frame = getframe(gcf);

if mod(size(frame.cdata, 1), 2) ~= 0
frame.cdata(end+1, :, :) = uint8(ones(1, size(frame.cdata, 2), 3) * 255);
end

if mod(size(frame.cdata, 2), 2) ~= 0
frame.cdata(:, end+1, :) = uint8(ones(size(frame.cdata, 1), 1, 3) * 255);
end
writeVideo(v, frame);
end
close(v);
Expand All @@ -44,9 +67,9 @@
scatter(X, Y, 100, cmap, "filled","MarkerEdgeColor", "k", "linewidth", 1.5);

%% 2D Transformation
% what_transform = "permutation";
what_transform = "permutation";
% what_transform = "rotation";
what_transform = "shear";
% what_transform = "shear";

switch what_transform
case "rotation"
Expand All @@ -61,7 +84,7 @@
v = VideoWriter("2d_"+what_transform+".mp4", "MPEG-4");
open(v);
plotXYPlane()
set(gcf,'position', [-669.0000 422.3333 530.6667 356.6667]);
set(gcf,'position', [669.0000 422.3333 530.6667 356.6667]);
hold on;
img = imread('cameraman.tif');
img = flipud(img);
Expand All @@ -88,6 +111,14 @@
view(2)
drawnow;
frame = getframe(gcf);

if mod(size(frame.cdata, 1), 2) ~= 0
frame.cdata(end+1, :, :) = uint8(ones(1, size(frame.cdata, 2), 3) * 255);
end

if mod(size(frame.cdata, 2), 2) ~= 0
frame.cdata(:, end+1, :) = uint8(ones(size(frame.cdata, 1), 1, 3) * 255);
end
writeVideo(v, frame);
if i_step < n_steps
delete(h);
Expand All @@ -97,6 +128,14 @@

for i = 1:30
frame = getframe(gcf);

if mod(size(frame.cdata, 1), 2) ~= 0
frame.cdata(end+1, :, :) = uint8(ones(1, size(frame.cdata, 2), 3) * 255);
end

if mod(size(frame.cdata, 2), 2) ~= 0
frame.cdata(:, end+1, :) = uint8(ones(size(frame.cdata, 1), 1, 3) * 255);
end
writeVideo(v, frame)
end

Expand All @@ -105,8 +144,8 @@
%% 3D Transformation

% what_transform = "rotation";
what_transform = "shear";
% what_transform = "reflection";
% what_transform = "shear";
what_transform = "reflection";

switch what_transform
case "rotation"
Expand Down Expand Up @@ -236,6 +275,13 @@

drawnow;
frame = getframe(gcf);
if mod(size(frame.cdata, 1), 2) ~= 0
frame.cdata(end+1, :, :) = uint8(ones(1, size(frame.cdata, 2), 3) * 255);
end

if mod(size(frame.cdata, 2), 2) ~= 0
frame.cdata(:, end+1, :) = uint8(ones(size(frame.cdata, 1), 1, 3) * 255);
end
writeVideo(v, frame);

if i_step < n_steps
Expand All @@ -245,6 +291,13 @@

for i = 1:30
frame = getframe(gcf);
if mod(size(frame.cdata, 1), 2) ~= 0
frame.cdata(end+1, :, :) = uint8(ones(1, size(frame.cdata, 2), 3) * 255);
end

if mod(size(frame.cdata, 2), 2) ~= 0
frame.cdata(:, end+1, :) = uint8(ones(size(frame.cdata, 1), 1, 3) * 255);
end
writeVideo(v, frame)
end

Expand Down
Binary file modified pics/2024-06-28-Affine_Transformation/vector2dot.mp4
Binary file not shown.

0 comments on commit 8259320

Please sign in to comment.