MATLAB Answers

making a folded picture

17 ビュー (過去 30 日間)
ahmed musse
ahmed musse 2021 年 8 月 30 日
コメント済み: ahmed musse 2021 年 9 月 23 日 22:05
the basic idea is to create a folded photo with a resolution of 1080 by 1920 ratio . it works by having a rotated object and the program would cut a rectangle from the middle of frames(1080-by-3 ) and it combines all the cropped photos in sequence to achieve a folding effect.
my basic code was like this:
%this code bring a frame of photo, crops from the centre, and combine the
%previous photo with the new one.
load('s.mat','s')
s; %a reference(1080-by-3) photo for the loop
target=[1080 3]; %the croped size
a=VideoReader('VID_20210828_184108.mp4'); %analyzes the video
for img= 1:640 % the number of frames needed for the photo
I=read(a,img); %read the frame
r=centerCropWindow2d(size(I),target); %creates a rectangle with the target size
j=imcrop(I,r); %crop the image to the target size
s=imfuse(s,j,'montage'); %combines the new cropped photo with the old ones
end
imshow(s)
when i run the code, the image turns to be way too big. i then discovered that (imfuse) fills up the image if the two fused images dont have the same dimensions. is there a function that combines photos as they are without filling up? thank you already

採用された回答

DGM
DGM 2021 年 8 月 30 日
編集済み: DGM 2021 年 8 月 30 日
If you want to edge-concatenate two images of the same height, you don't need to waste your time with imfuse.
s = [s j];
If the image heights differ, you'll have to fix that by resizing/padding/cropping before the loop.
Keep in mind that if you want edge-continuity like a folded image, you'd have to flip every other sub-image.
  1 件のコメント
ahmed musse
ahmed musse 2021 年 9 月 23 日 22:05
Thank you it worked! The pictures that I made are not that quality but still I am happy with the results.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by