[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
image read/write routines
From: |
etienne grossmann |
Subject: |
image read/write routines |
Date: |
Mon, 26 Jun 2000 20:38:20 +0100 (WEST) |
Hello,
I have some functions taking images as input, in which I don't know
in advance whether I will get RGB or graylevel images.
One way is to pass an extra argument to specify the image
type. However, I don't like multiplying the arguments to my
functions. So I store images in a structure -say "X"- with fields :
X.im : H x W matrix for graylevel images
H x 3W matrix for rgb images, stored as [r1,g1,b1,..,gW,bW]
X.rgb : 0 or 1 : indicates whether image is RGB or graylevel
X.maxval : The maximal value of elements in X.im.
Wrapping up slightly modified (copyright unchanged) versions Ariel
Tankus's image functions, I have small library with the following
functions :
Ariel Tankus's image functions (manipulate matrices) :
---------------------------------------------------------
writefi writefi(fname, im)
writegif writegif(fname, im)
writegraygif writegraygif(fname, im)
writejpg writejpg(fname, im)
writegrayjpg writegrayjpg(fname, im)
writepgm writepgm(fname, im)
writegrayps writegrayps(fname, im, dpi)
writepnm writepnm(fname, im, isPpm)
writeppm writeppm(fname, im)
readfi im = readfi(fname)
readgif [im, isPpm,maxval] = readgif(fname)
readpnm [im, isPpm] = readpnm(fname)
readgrayjpg im = readgrayjpg(fname)
readjpg [im, isPpm] = readjpg(fname)
readimagefile [im, isPpm, maxval] = readimagefile(fname, force_gray)
getmagicnum Copyright (C) 1998 Ariel Tankus
mergeppm im = mergeppm(r, g, b)
splitppm [r g b] = splitppm(im)
New functions (manipulate structures)
----------------------------------------
ims_load ims = ims_load ( imfile ) - Load an image, returning a sructure
ims_save ok = ims_save (ims, file [, fmt])
ims_show ims = ims_show ( im [, pix] )
ims_size [h,w] = ims_size (im) - Returns the size, in pixels of the image.
test_ims Check whether ims functions work as they should
is_ims ok = is_ims (ims)
set_viewer vc2 = set_viewer( [vc] )
rgb2gray gr = rgb2gray( rgb ) - convert rgb to graylevel.
gray2rgb rgb = gray2rgb( gr ) - convert graylevel to rgb
Needed utilities :
------------------
struct s = struct(key1,val1,...)
getNonComment Copyright (C) 1998 Ariel Tankus
filename_ext ext = filename_ext( fname )
If anyone is interested, I have put these functions (html tree and
tarball) at :
http://anonimo.isr.ist.utl.pt:8080/~etienne/octave/index.html
Cheers,
Etienne
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- image read/write routines,
etienne grossmann <=