help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rgb2ind issue


From: RT
Subject: rgb2ind issue
Date: Thu, 26 Jul 2018 16:35:37 -0400

I'm trying to create an animated gif using code I found at https://www.mathworks.com/matlabcentral/answers/94495-how-can-i-create-animated-gif-images-in-matlab
but I get an error
"error: Invalid call to rgb2ind.  Correct usage is:

 -- [X, MAP] = rgb2ind (RGB)
 -- [X, MAP] = rgb2ind (R, G, B)

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at https://www.octave.org and via the address@hidden
mailing list."

The code is below.  Are there any workarounds?

h = figure;
axis tight manual % this ensures that getframe() returns a consistent size
filename = 'testAnimated.gif';
for n = 1:0.5:5
    % Draw plot for y = x.^n
    x = 0:0.01:1;
    y = x.^n;
    plot(x,y)
    drawnow
      % Capture the plot as an image
      frame = getframe(h);
      im = frame2im(frame);
      [imind,cm] = rgb2ind(im,256);
      % Write to the GIF File
      if n == 1
          imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
      else
          imwrite(imind,cm,filename,'gif','WriteMode','append');
      end
  end


​Ps I tried with

----------------------------------------------------------------------
GNU Octave Version: 4.4.0 (hg id: d703d8bbc6ae)
GNU Octave License: GNU General Public License
Operating System: Linux 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64
----------------------------------------------------------------------
Package Name  | Version | Installation directory
--------------+---------+-----------------------
     control  |   3.1.0 | /home/rt/octave/control-3.1.0
      signal  |   1.4.0 | /home/rt/octave/signal-1.4.0
>>​

--
--

reply via email to

[Prev in Thread] Current Thread [Next in Thread]