On Wednesday 05 September 2001 08:54, Alessandro Mirone wrote:
| Hallo,
| I am wondering if there is an analog of pgplot's pgimage routine
| and if not how could one deal with images using plplot.
I forgot this one. Sorry for the delay--of course you don't need it=20
anymore :).
If your images are small and monocrome, plshade() with a gray=20
colormap works OK. With a 349x239 color image *octave* took 5 sec to=20
draw it. Of course, you can code it in other language.
octave-2.1.34:2> img =3D jepg2gray("~jcard/pic/pic9.jpg");
octave-2.1.34:3> size(img)
ans =3D
349 239
octave-2.1.34:4> plcolormap (gray);
octave-2.1.34:10> tic; t=3Dcputime; shade(img); cputime-t, toc
ans =3D 2.5400=20
ans =3D 4.6722
2.5 sec of CPU, 4.7 sec of wall clock.
The (very old) used functions:
------------------------------------------------
function gray =3D jepg2gray(file)
o_file =3D tmpnam;
system(sprintf("djpeg %s > %s",file, o_file));
gray =3D ppm2gray(o_file);
system(sprintf("rm -f %s", o_file));
endfunction
-----------------------------------------------------
function gray =3D 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=20
separated by space
# xwpick-2.10 also
# octave... should really use 'octtopnm', its much faster for _real_=20
pictures...
# all use P6/P3 as ppm format.
fp=3Dfopen(file,"r");
ver=3Dfscanf(fp,"%s%*c","C"); # get version
a=3D'#'; # get rid of xv=20
comments
while (a(1,1) =3D=3D '#')
pos =3D ftell(fp);
a=3Dfgetl(fp);
endwhile
fseek(fp,pos);
[xx yy max_c] =3D fscanf(fp,"%d%d%d","C"); # get number of x and=20
y pixels
if ( ver(1,2) =3D=3D '6' | ver(1,2) =3D=3D '5' ) =
=20
=20
a=3Dfread(fp,[xx*3 yy],"uchar"); # read data
elseif (ver(1,2) =3D=3D '3' ) # ascii forma=
t
a =3D fscanf(fp,"%d", [xx*3 yy]);
# a =3D fscanf(fp,"%d"); # octave=20
hangup!
else
fclose(fp);
error("ppm2gray: only process ascii/rawbit, P3/P6, format=20
files")
return
endif
=20
r=3Da(1:3:xx*3,:);
g=3Da(2:3:xx*3,:);
b=3Da(3:3:xx*3,:);
=20
gray =3D (r.+g.+b)'./(3*max_c);
fclose(fp);
endfunction
|
| Thanks
| Alessandro Mirone
|
| _______________________________________________
| Plplot-general mailing list
| Plp...@li...
| https://lists.sourceforge.net/lists/listinfo/plplot-general
|