From: <and...@us...> - 2008-07-25 08:50:09
|
Revision: 8591 http://plplot.svn.sourceforge.net/plplot/?rev=8591&view=rev Author: andrewross Date: 2008-07-25 08:50:17 +0000 (Fri, 25 Jul 2008) Log Message: ----------- Add plimagefr support to octave bindings and update example 20 to use this. Modified Paths: -------------- trunk/bindings/octave/demos/x20c.m trunk/bindings/octave/plplot_octave.h.in Modified: trunk/bindings/octave/demos/x20c.m =================================================================== --- trunk/bindings/octave/demos/x20c.m 2008-07-25 00:15:29 UTC (rev 8590) +++ trunk/bindings/octave/demos/x20c.m 2008-07-25 08:50:17 UTC (rev 8591) @@ -84,7 +84,7 @@ elseif (exist("../lena.pgm","file")) [ret, img, width, height, num_col] = read_img("../lena.pgm"); else - plabort("No such file"); + printf("Error: No such file\n"); plend1; return; endif @@ -146,6 +146,34 @@ pladv(0); endif + ## Base the dynamic range on the image contents. + + img_max = max(max(img)); + img_min = min(min(img)); + + plcol(2) + plenv(0., width, 0., height, 1, -1) + pllab("", "", "Reduced dynamic range image example") + plimagefr(img, 0., width, 0., height, 0., 0., img_min + img_max * 0.25, img_max - img_max * 0.25) + + ## Draw a distorted version of the original image, showing its + ## full dynamic range. + plenv(0., width, 0., height, 1, -1) + pllab("", "", "Distorted image example") + + ## Populate the 2-d grids used for the distortion + ## NB grids must be 1 larger in each dimension than the image + ## since the coordinates are for the corner of each pixel. + x0 = 0.5*width; + y0 = 0.5*height; + dy = 0.5*height; + stretch = 0.5; + xg = [0:width]'*ones(1,height+1); + yg = ones(width+1,1)*[0:height]; + xg = x0 + (x0-xg).*(1-stretch*cos((yg-y0)/dy*pi*0.5)); + plimagefr2(img, 0., width, 0., height, 0., 0., img_min, img_max, xg, yg); + pladv(0) + plend1; endfunction Modified: trunk/bindings/octave/plplot_octave.h.in =================================================================== --- trunk/bindings/octave/plplot_octave.h.in 2008-07-25 00:15:29 UTC (rev 8590) +++ trunk/bindings/octave/plplot_octave.h.in 2008-07-25 08:50:17 UTC (rev 8591) @@ -1673,11 +1673,20 @@ * convention as plcont */ void my_plimagefr(PLFLT *a, PLINT nx, PLINT ny, - PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT zmin, PLFLT zmax, - PLFLT valuemin, PLFLT valuemax, PLFLT *tr) { + PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, + PLFLT zmin, PLFLT zmax, + PLFLT valuemin, PLFLT valuemax) { f2c(a,aa,nx,ny); + plimagefr(aa,nx,ny,xmin,xmax,ymin,ymax,zmin,zmax,valuemin,valuemax,NULL,NULL); +} //%name plimagefr //%input a(nx,ny) + +void my_plimagefrx(PLFLT *a, PLINT nx, PLINT ny, + PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, + PLFLT zmin, PLFLT zmax, + PLFLT valuemin, PLFLT valuemax, PLFLT *tr) { + f2c(a,aa,nx,ny); plimagefr(aa,nx,ny,xmin,xmax,ymin,ymax,zmin,zmax,valuemin,valuemax,xform,tr); -} //%name plimagefr //%input a(nx,ny), tr(6) +} //%name plimagefrx //%input a(nx,ny), tr(6) /* plimagefr() for use with pltr1 */ void my_plimagefr1(PLFLT *a, PLINT nx, PLINT ny, @@ -1685,11 +1694,11 @@ PLFLT zmin, PLFLT zmax, PLFLT valuemin, PLFLT valuemax, PLFLT *xg, PLFLT *yg) { PLcGrid grid1; - grid1.nx = nx; grid1.ny = ny; + grid1.nx = nx+1; grid1.ny = ny+1; grid1.xg = xg; grid1.yg = yg; f2c(a,aa,nx,ny); c_plimagefr(aa,nx,ny,xmin,xmax,ymin,ymax,zmin,zmax,valuemin,valuemax,pltr1,&grid1); -} //%name plimagefr1 //%input a(nx,ny), xg(nx), yg(ny) +} //%name plimagefr1 //%input a(nx,ny), xg(nx+1), yg(ny+1) /* plimagefr() for use with pltr2 */ void my_plimagefr2(PLFLT *a, PLINT nx, PLINT ny, @@ -1697,12 +1706,12 @@ PLFLT zmin, PLFLT zmax, PLFLT valuemin, PLFLT valuemax, PLFLT *xg, PLFLT *yg) { PLcGrid2 grid2; - f2c(xg,xgg,nx,ny); f2c(yg,ygg,nx,ny); - grid2.nx = nx; grid2.ny = ny; + f2c(xg,xgg,(nx+1),(ny+1)); f2c(yg,ygg,(nx+1),(ny+1)); + grid2.nx = nx+1; grid2.ny = ny+1; grid2.xg = xgg; grid2.yg = ygg; f2c(a,aa,nx,ny); c_plimagefr(aa,nx,ny,xmin,xmax,ymin,ymax,zmin,zmax,valuemin,valuemax,pltr2,&grid2); -} //%name plimagefr2 //%input a(nx,ny), xg(nx,ny), yg(nx,ny) +} //%name plimagefr2 //%input a(nx,ny), xg(nx+1,ny+1), yg(nx+1,ny+1) /* Depreciated functions - retained for backwards compatibility */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |