I'm having problems copying a 4-D array

1 回表示 (過去 30 日間)
Connor Hogarth
Connor Hogarth 2021 年 4 月 12 日
コメント済み: Connor Hogarth 2021 年 4 月 12 日
The code is as follows:
for t = 1;1;frames;
gifout(:,:,:,t) = uint8(gifin(:,:,1,t));
end
I am trying to copy a gif (stored as a 4-d array) with only a single colour dimension, where t is the amount of frames in the gif. The problem is that it is returning a single image rather than a series of images. What would be the correct way of implementing this?
As a side note, using
gifout(:,:,:,t) = uint8(gifin(:,:,:,t));
returns the error "Assignment has more non-singleton rhs dimensions than non-singleton subscripts", but I expected it to directly copy all frames. Can this be explained to me?
Thanks
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 4 月 12 日
for t = 1;1;frames;
^ ^
Did you use the : operator in your actual code?
Is there a reason you did not use
gifout = im2uint8(gifin);
with no loop?
Connor Hogarth
Connor Hogarth 2021 年 4 月 12 日
Because, I'm dumb. Thanks for the help, maybe I should get some sleep

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

採用された回答

Matt J
Matt J 2021 年 4 月 12 日
for t = 1:frames

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 4 月 12 日
To read all of the frames for gif in your release, use 'Frames', 'all' in your imread() call.
Whether imread() reads all frames of gif by default, or only one frame, is something that changed between your release and current releases.

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by