image handling problems in Octave 3.2.2 under CentOS 5.3

View: New views
1 Messages — Rating Filter:   Alert me  

image handling problems in Octave 3.2.2 under CentOS 5.3

by Les Klimczak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here are some issues I encountered while trying to get Octave 3.2.2 to work under CentOS 5.3.

Les Klimczak, Ph.D.
Research Informatics Consultant
San Francisco, CA - Madison, WI - Gaithersburg, MD

1. 'imshow' will still call gnuplot even if version 4.2 is not available (gnuplot-4.0.0-14.el5 comes with the system) and image_viewer("/usr/bin/display %s") was set. In addition to giving gnuplot errors, this exposes a potential bug in imshow.m et al.:
error: Invalid call to strcat.  Correct usage is:

 -- Function File:  strcat (S1, S2, ...)

This originates from __gnuplot_get_var__.m when an empty cell object is passed to 'strcat'

octave:211> strcat(str{:})
ans = aabb
octave:212> str2 = {};
octave:213> strcat(str2{:})
error: Invalid call to strcat.  Correct usage is:

 -- Function File:  strcat (S1, S2, ...)

To fix this, I checked for this condition:

diff -cr octave-3.2.2/scripts/plot/__gnuplot_get_var__.m octave-3.2.2/scripts/plot/__gnuplot_get_var__.m.fix
*** octave-3.2.2/scripts/plot/__gnuplot_get_var__.m     2009-06-02 00:22:16.0000
00000 -0500
--- octave-3.2.2/scripts/plot/__gnuplot_get_var__.m.fix 2009-07-30 17:45:38.0000
00000 -0500
***************
*** 110,116 ****
            str = str(1:(end-1));
          endif
        endwhile
!       str = strcat (str{:});
        fclose (gpin);
      else
        ## Direct gnuplot to print to <STDOUT>
--- 110,122 ----
            str = str(1:(end-1));
          endif
        endwhile
!
!       if (length(str)==0)
!                       str = ""
!                       else
!                       str = strcat (str{:});
!                       endif
!
        fclose (gpin);
      else
        ## Direct gnuplot to print to <STDOUT>

This problem stopped manifesting itself after I upgraded to gnuplot-4.2.5.tar.gz


2. in saveimage.m, 'map' is assumed to have always real values 0:1, but rgb2ind(img) generates it as integers 0:255. This results in color images having only primary colors.

Again, I introduced a check:

diff -cr octave-3.2.2/scripts/image/saveimage.m octave-3.2.2/scripts/image/saveimage.m.fix
*** octave-3.2.2/scripts/image/saveimage.m      2009-05-25 01:04:59.000000000 -0
500
--- octave-3.2.2/scripts/image/saveimage.m.fix  2009-07-30 19:40:17.000000000 -0
500
***************
*** 129,138 ****
--- 129,140 ----
 
    map = reshape (map, map_sz, 1);
 
+       if (max(map) < 2)
    map (map > 1) = 1;
    map (map < 0) = 0;
 
    map = round (255 * map);
+       endif
 
    bw = (map_nr == 2
          && ((map(1,1) == 0 && map(2,1) == 255)