Image Processing Toolbox

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Image Processing Toolbox

Shahid.Masud
Hi,

Has anybody used the image processing toolbox available from octave's
contribution archive. I tried to use it on version 1.1.1 and 2.0.2 but
to no luck. A function called "isreal" has been used in all .m files of
image toolbox but is not defined anywhere.

If anybody has got some test images in octave format (like lena, barbara)
or infact any images, it is a good idea to make them a part of image
processing toolbox for experimentation and serious work. The image
"default.img" supplied with octave distribution is good but not enough.
Especially, if anybody has got a script to translate images in .mat or
.gif to octave's .img format, I feel it should be shared to enhance the
utility of octave in image processing.

Thanks,
Shahid

Reply | Threaded
Open this post in threaded view
|

Image Processing Toolbox

Kurt Hornik-2
>>>>> On Thu, 30 Jan 97 08:04:58 GMT,
>>>>> [hidden email] said:

> Hi,
> Has anybody used the image processing toolbox available from octave's
> contribution archive. I tried to use it on version 1.1.1 and 2.0.2 but
> to no luck. A function called "isreal" has been used in all .m files of
> image toolbox but is not defined anywhere.

You can use e.g.

function y = isreal (x)
 
  # Usage:  isreal (x)
  #
  # Returns 1 if x is real (scalar, vector or matrix), otherwise 0.
 
  y = all (all (x == real (x)));
 
endfunction

To use imagep, you also need to do the following in conv2.m:

        elseif (strcmp(area, "valid")
                                     *
Add a `)' where the * is.

-kh

Reply | Threaded
Open this post in threaded view
|

Re: Image Processing Toolbox

Joao Cardoso-8
In reply to this post by Shahid.Masud


[hidden email]  wrote:
 | Hi,
 |
 | Has anybody used the image processing toolbox available from octave's
 | contribution archive. I tried to use it on version 1.1.1 and 2.0.2 but
 | to no luck. A function called "isreal" has been used in all .m files of
 | image toolbox but is not defined anywhere.
 |
 | If anybody has got some test images in octave format (like lena, barbara)
 | or infact any images, it is a good idea to make them a part of image
 | processing toolbox for experimentation and serious work. The image
 | "default.img" supplied with octave distribution is good but not enough.
 | Especially, if anybody has got a script to translate images in .mat or
 | .gif to octave's .img format, I feel it should be shared to enhance the
 | utility of octave in image processing.

Hi,

You can try the .m functions bellow. I found 'ppm' to be the best
format to use with octave. No exaustive testing. On _real_ images
octave is Very slow. With color images, the colormap created has as
many entries as pixels in the image! No sharing... The 'saveimage'
could use 'octtopnm', which is distributed in the sources, and is
much faster; the source only needs a small change to work, and of
course 'saveimage' needs a small change:  

*** saveimage.m Mon Dec 16 00:28:25 1996
--- /usr/local/share/octave/2.0.2/m/image/saveimage.m Thu Jan 30 02:17:19 1997
***************
*** 107,126 ****
    endif
 
    ## If we just want Octave image format, save and return.
    if (strcmp (img_form, "img"))
      eval (strcat ("save -ascii ", filename, " map img"));
      return;
    endif
 
    ## Convert to another format if requested.
! #jc: just use octtopnm!
!   if (strcmp (img_form, "ppm"))
!     eval (strcat ("save -ascii ", filename, ". map img"));
! system(strcat("octtopnm \"", filename, ".\" >", filename));
! system(strcat("rm -f ", filename, "."));
! return
!  endif
!  
    grey = all (map(:,1) == map(:,2) && map(:,1) == map (:,3));
 
    pbm = pgm = ppm = 0;


_________________________________________________________________
function gray = ppm2gray(file)

# ppm2gray: raw/ascii ppm picture to gray image format
#
# xv-3.10a stores each header line on a separate line, \n separated
# giftoppm is identical to xv
# in xloadimage-4.0 there is only one header line, parameters separated by space
# xwpick-2.10 also
# octave... should really use 'octtopnm', its much faster for _real_ pictures...
# all use P6/P3 as ppm format.

fp=fopen(file,"r");
ver=fscanf(fp,"%s%*c","C"); # get version

a='#'; # get rid of xv comments
while (a(1,1) == '#')
        pos = ftell(fp);
        a=fgetl(fp);
endwhile

fseek(fp,pos);
[xx yy max_c] = fscanf(fp,"%d%d%d","C"); # get number of x and y pixels

if ( ver(1,2) == '6' ) # raw format
        a=fread(fp,[xx*3 yy],"uchar"); # read data
elseif (ver(1,2) == '3' ) # ascii format
        a = fscanf(fp,"%d", [xx*3 yy]);
else
        fclose(fp);
        error("ppm2gray: only process ascii/rawbit, P3/P6, format files")
        return
endif
       
        r=a(1:3:xx*3,:);
        g=a(2:3:xx*3,:);
        b=a(3:3:xx*3,:);
       
        gray = (r.+g.+b)'./(3*max_c);

fclose(fp);

endfunction

____________________________________________________________
function [r g b] = ppm2rgb(file)

# ppm2oct: raw ppm picture to gray image format
#
# xv-3.10a stores each header line on a separate line, \n separated
# giftoppm is identical to xv
# in xloadimage-4.0 there is only one header line, parameters separated by space
# xwpick-2.10 also
# octave ...
# all use P6 as ppm format.

fp=fopen(file,"r");
ver=fscanf(fp,"%s%*c","C"); # get version
if ( ver(1,2) != '6' )
        error("ppm2oct: only process rawbit, P6, format files")
        return
endif

a='#'; # get rid of xv comments
while (a(1,1) == '#')
        pos = ftell(fp);
        a=fgetl(fp);
endwhile

fseek(fp,pos);
[xx yy max_c] = fscanf(fp,"%d%d%d","C"); # get number of x and y pixels

a=fread(fp,[xx*3 yy],"uchar"); # read data

r=a(1:3:xx*3,:)'./max_c;
g=a(2:3:xx*3,:)'./max_c;
b=a(3:3:xx*3,:)'./max_c;

fclose(fp);

endfunction

____________________________________________________________
function gray = gif2gray(file)

o_file = tmpnam;
system(sprintf("giftoppm %s > %s",file, o_file));

gray = ppm2gray(o_file);

system(sprintf("rm -f %s", o_file));
endfunction

--
Joao Cardoso, INESC  |  e-mail: [hidden email]
R. Jose Falcao 110   |  tel:    + 351 2 2094345
4050 Porto, Portugal |  fax:    + 351 2 2008487





--
Joao Cardoso, INESC  |  e-mail: [hidden email]
R. Jose Falcao 110   |  tel:    + 351 2 2094345
4050 Porto, Portugal |  fax:    + 351 2 2008487