bugGNU Octave - Bugs: bug #54392, Matlab compatibility: syntax...

 
 

bug #54392: Matlab compatibility: syntax rgb2ind (img,N) to create a dithered image missing

Submitted by:  Rick T <ratulloch>
Submitted on:  Fri 27 Jul 2018 03:00:12 AM UTC  
 
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 27 Jul 2018 03:55:38 PM UTC, comment #1:

I'm not sure when Matlab added the calling form rgb2ind (img, N), but it was probably in the last 2-3 years.

I've changed the Summary to reflect the true issue. Someone who understands image processing will need to help on this issue and code up an initial implementation of the algorithm. Core developers can then polish it for performance and to adhere to Octave coding conventions.

Rik <rik5>
Project Administrator
Fri 27 Jul 2018 03:00:12 AM UTC, original submission:

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 -email is unavailable-
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

Nicholas Jankowski said the function is different from matlab and I should post a bug. See he's email he sent below

Looking at the function calling structure on matlab:

https://www.mathworks.com/help/matlab/ref/rgb2ind.html

[X,map] = rgb2ind(RGB,n)
X = rgb2ind(RGB, map)
[X,map] = rgb2ind(RGB, tol)
[___] = rgb2ind(_,dither_option)

and octave:

https://octave.sourceforge.io/octave/function/rgb2ind.html

[x, map] = rgb2ind (rgb)
[x, map] = rgb2ind (R, G, B)

it appears that the current Octave implementation is not fully compatible. Unless there's already something on the bug tracker that I didn't see in a quick search, it should probably be logged as one:

Rick T <ratulloch>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by ratulloch (Submitted the item)
  • -email is unavailable- added by ratulloch
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-07-27 rik5 Severity3 - Normal => 1 - Wish
        StatusNone => Confirmed
        Release4.4.0 => dev
        Summaryrgb2ind issue and images / gif creation => Matlab compatibility: syntax rgb2ind (img,N) to create a dithered image missing
    2018-07-27 ratulloch Carbon-Copy- => Added -email is unavailable-

    Back to the top


    Powered by Savane 3.3