From 390fd643a37603b2458253351466b2521b6116ce Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 1 Feb 2011 13:27:50 +0000 Subject: [PATCH] move im_dif_std() to almostdeprecated im_dif_std() is another ancient function which I don't want to update. You can now make this function with a simple combination of other vips operations. This patch includes gtk-doc for im_benchamrk.c --- ChangeLog | 2 + libvips/deprecated/Makefile.am | 1 + libvips/{other => deprecated}/im_dif_std.c | 37 ++ libvips/include/vips/almostdeprecated.h | 16 + libvips/include/vips/other.h | 14 - libvips/other/Makefile.am | 4 - libvips/other/cooc_funcs.c | 474 --------------------- libvips/other/glds_funcs.c | 256 ----------- libvips/other/im_benchmark.c | 43 +- libvips/other/im_meanstd.c | 136 ------ libvips/other/other_dispatch.c | 4 +- 11 files changed, 91 insertions(+), 896 deletions(-) rename libvips/{other => deprecated}/im_dif_std.c (76%) delete mode 100644 libvips/other/cooc_funcs.c delete mode 100644 libvips/other/glds_funcs.c delete mode 100644 libvips/other/im_meanstd.c diff --git a/ChangeLog b/ChangeLog index 4674c99e..2d046948 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ - im_fits2vips() is lazy and much faster - im__file_open_write() / _read() has a flag for text_mode, get rid of all the remaining fopen()s +- move cooc_* and glds_* to deprecated +- move im_dif_std() to almostdeprecated 30/11/10 started 7.24.0 - bump for new stable diff --git a/libvips/deprecated/Makefile.am b/libvips/deprecated/Makefile.am index 61e28f1a..83af88dd 100644 --- a/libvips/deprecated/Makefile.am +++ b/libvips/deprecated/Makefile.am @@ -2,6 +2,7 @@ noinst_LTLIBRARIES = libdeprecated.la libdeprecated_la_SOURCES = \ deprecated_dispatch.c \ + im_dif_std.c \ cooc_funcs.c \ glds_funcs.c \ im_fav4.c \ diff --git a/libvips/other/im_dif_std.c b/libvips/deprecated/im_dif_std.c similarity index 76% rename from libvips/other/im_dif_std.c rename to libvips/deprecated/im_dif_std.c index c4249e2a..3c6a3a59 100644 --- a/libvips/other/im_dif_std.c +++ b/libvips/deprecated/im_dif_std.c @@ -50,6 +50,43 @@ #include #endif /*WITH_DMALLOC*/ +static int +im__mean_std_int_buffer( int *buffer, int size, + double *pmean, double *pstd ) +{ + double mean, std; + register int i; + int sumf; + int temp; + int *pbuffer; + int sumf2; + double correction; /* calulates the correction term for the variance */ + double variance; /* = (sumf2 - correction)/n */ + + if (size <= 0) { + im_error( "im_mean_std_int_buffer", "%s", _( "wrong args") ); + return(-1); + } + + mean = 0.0; std = 0.0; + sumf = 0; sumf2 = 0; + pbuffer = buffer; + for (i=0; i -#endif /*HAVE_CONFIG_H*/ -#include - -#include -#include -#include - -#include - -#ifdef WITH_DMALLOC -#include -#endif /*WITH_DMALLOC*/ - -static -int im_cooc_sym(im, m, xpos, ypos, xsize, ysize, dx, dy) -IMAGE *im, *m; -int xpos, ypos, xsize, ysize; /* location of the box within im */ -int dx, dy; /* displacements */ -{ - PEL *input, *cpinput; - int *buf, *pnt, *cpnt; - double *line, *cpline; - int x, y; - int offset; - int bufofst; - int tempA, tempB; - int norm; - - if (im_iocheck(im, m) == -1) - return( -1 ); - if ((im->Bands != 1)||(im->BandFmt != IM_BANDFMT_UCHAR)) { - im_error( "im_cooc_sym", "%s", _( "Unable to accept input") ); - return(-1); - } - if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) { - im_error( "im_cooc_sym", "%s", _( "wrong args") ); - return(-1); } - if (im_cp_desc(m, im) == -1) - return( -1 ); - m->Xsize = 256; - m->Ysize = 256; - m->BandFmt = IM_BANDFMT_DOUBLE; - m->Type = IM_TYPE_B_W; - if (im_setupout(m) == -1) - return( -1 ); -/* malloc space to keep the read values */ - buf = (int *)calloc( (unsigned)m->Xsize*m->Ysize, sizeof(int) ); - line = (double *)calloc( (unsigned)m->Xsize * m->Bands, sizeof(double)); - if ( (buf == NULL) || (line == NULL) ) { - im_error( "im_cooc_sym", "%s", _( "calloc failed") ); - return(-1); } - input = (PEL*)im->data; - input += ( ypos * im->Xsize + xpos ); - offset = dy * im->Xsize + dx; - for ( y=0; yXsize; - for ( x=0; xXsize * tempB; - (*(buf + bufofst))++; - bufofst = tempB + m->Xsize * tempA; - (*(buf + bufofst))++; - cpinput++; - } - } - - norm = xsize * ysize * 2; - pnt = buf; - for ( y=0; yYsize; y++ ) - { - cpnt = pnt; - pnt += m->Xsize; - cpline = line; - for (x=0; xXsize; x++) - *cpline++ = (double)(*cpnt++)/(double)norm; - if (im_writeline( y, m, (PEL *) line ) == -1) - { - im_error( "im_cooc_sym", "%s", _( "unable to im_writeline") ); - return(-1); - } - } - free((char*)buf); - free((char*)line); - return(0); -} - -static -int im_cooc_ord(im, m, xpos, ypos, xsize, ysize, dx, dy) -IMAGE *im, *m; -int xpos, ypos, xsize, ysize; /* location of the box within im */ -int dx, dy; /* displacements */ -{ - PEL *input, *cpinput; - int *buf, *pnt, *cpnt; - double *line, *cpline; - int x, y; - int offset; - int bufofst; - int tempA, tempB; - int norm; - - if (im_iocheck(im, m) == -1) - return( -1 ); - if ((im->Bands != 1)||(im->BandFmt != IM_BANDFMT_UCHAR)) - { - im_error( "im_cooc_ord", "%s", _( "Unable to accept input") ); - return(-1); - } - if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) { - im_error( "im_cooc_ord", "%s", _( "wrong args") ); - return(-1); } - if (im_cp_desc(m, im) == -1) - return( -1 ); - m->Xsize = 256; - m->Ysize = 256; - m->BandFmt = IM_BANDFMT_DOUBLE; - if (im_setupout(m) == -1) - return( -1 ); -/* malloc space to keep the read values */ - buf = (int *)calloc( (unsigned)m->Xsize*m->Ysize, sizeof(int) ); - line = (double *)calloc( (unsigned)m->Xsize * m->Bands, sizeof(double)); - if ( (buf == NULL) || (line == NULL) ) { - im_error( "im_cooc_ord", "%s", _( "calloc failed") ); - return(-1); } - input = (PEL*)im->data; - input += ( ypos * im->Xsize + xpos ); - offset = dy * im->Xsize + dx; - for ( y=0; yXsize; - for ( x=0; xXsize * tempB; - (*(buf + bufofst))++; - cpinput++; - } - } - - norm = xsize * ysize; - pnt = buf; - for ( y=0; yYsize; y++ ) - { - cpnt = pnt; - pnt += m->Xsize; - cpline = line; - for (x=0; xXsize; x++) - *cpline++ = (double)(*cpnt++)/(double)norm; - if (im_writeline( y, m, (PEL *) line ) == -1) - { - im_error( "im_cooc_ord", "%s", _( "unable to im_writeline") ); - return(-1); - } - } - free((char*)buf); - free((char*)line); - return(0); -} - -/* Keep the coocurrence matrix as a 256x256x1 double image */ - -int -im_cooc_matrix( IMAGE *im, IMAGE *m, - int xp, int yp, int xs, int ys, int dx, int dy, int flag ) -{ - if (flag == 0) - return( im_cooc_ord(im, m, xp, yp, xs, ys, dx, dy) ); - else if (flag == 1) /* symmetrical cooc */ - return( im_cooc_sym(im, m, xp, yp, xs, ys, dx, dy) ); - else { - im_error( "im_cooc_matrix", "%s", _( "wrong flag!") ); - return(-1); } -} - -/* Calculate contrast, asmoment, entropy and correlation - */ -int -im_cooc_asm( IMAGE *m, double *asmoment ) -{ - double temp, tmpasm, *pnt; - int i; - - if( im_incheck( m ) ) - return( -1 ); - - if (m->Xsize != 256 || m->Ysize != 256 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) - { - im_error( "im_cooc_asm", "%s", _( "unable to accept input") ); - return(-1); - } - tmpasm = 0.0; - pnt = (double*)m->data; - for(i=0; iXsize * m->Ysize; i++) - { - temp = *pnt++; - tmpasm += temp * temp; - } - *asmoment = tmpasm; - return(0); -} - -int -im_cooc_contrast( IMAGE *m, double *contrast ) -{ - double dtemp, tmpcon, *pnt, *cpnt; - int x, y; - - if( im_incheck( m ) ) - return( -1 ); - - if (m->Xsize != 256 || m->Ysize != 256 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) - { - im_error( "im_cooc_contrast", "%s", _( "unable to accept input") ); - return(-1); - } - tmpcon = 0.0; - pnt = (double*)m->data; - for(y=0; yYsize; y++) - { - cpnt = pnt; - pnt += m->Xsize; - for(x=0; xXsize; x++) - { - dtemp = (double)( (y-x)*(y-x) ); - tmpcon += dtemp * (*cpnt); - cpnt++; - } - } - - *contrast = tmpcon; - return(0); -} - -static void -stats(buffer, size, pmean, pstd) -double *buffer; /* buffer contains the frequency distributions f[i] */ -int size; /* Note that sum(f[i]) = 1.0 and that the */ - /* cooccurence matrix is symmetrical */ -double *pmean, *pstd; -{ - double mean, std; - register int i; - double sumf; /* calculates the sum of f[i] */ - double temp; /* temporary variable */ - double *pbuffer; - double sumf2; /* calculates the sum of f[i]^2 */ - double correction; /* calulates the correction term for the variance */ - double variance; /* = (sumf2 - correction)/n, n=sum(f[i]) = 1 */ - - mean = 0.0; std = 0.0; - sumf = 0.0; sumf2 = 0.0; - pbuffer = buffer; - for (i=0; iXsize != 256 || m->Ysize != 256 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) - { - im_error( "im_cooc_correlation", "%s", _( "unable to accept input") ); - return(-1); - } - row = (double*)calloc( (unsigned)m->Ysize, sizeof(double)); - col = (double*)calloc( (unsigned)m->Xsize, sizeof(double)); - if ( row == NULL || col == NULL ) - { - im_error( "im_cooc_correlation", "%s", _( "unable to calloc") ); - return(-1); - } - pbuf = (double*)m->data; - for(j=0; jYsize; j++) - { - cpbuf = pbuf; - pbuf += m->Xsize; - sum=0.0; - for(i=0; iXsize; i++) - sum += *cpbuf++; - *(row+j) = sum; - } - - pbuf = (double*)m->data; - for(j=0; jYsize; j++) - { - cpbuf = pbuf; - pbuf++; - sum=0.0; - for(i=0; iXsize; i++) - { - sum += *cpbuf; - cpbuf += m->Xsize; - } - *(col+j) = sum; - } - - stats(row, m->Ysize, &mrow, &stdrow); - - stats(col, m->Ysize ,&mcol, &stdcol); -#ifdef DEBUG - fprintf(stderr, "rows: mean=%f std=%f\ncols: mean=%f std=%f\n", -mrow, stdrow, mcol, stdcol); -#endif - tmpcor = 0.0; - pbuf = (double*)m->data; - for(j=0; jYsize; j++) - { - cpbuf = pbuf; - pbuf += m->Xsize; - for(i=0; iXsize; i++) - { - dtemp = *cpbuf; - tmpcor += ( ((double)i)*((double)j)*dtemp); - cpbuf++; - } - } -#ifdef DEBUG - fprintf(stderr, "tmpcor=%f\n", tmpcor); -#endif - if ( (stdcol==0.0)||(stdrow==0) ) - { - im_error( "im_cooc_correlation", "%s", _( "zero std") ); - return(-1); - } - tmpcor = (tmpcor-(mcol*mrow))/(stdcol*stdrow); - *correlation = tmpcor; - free((char*)row); free((char*)col); - return(0); -} - -int -im_cooc_entropy( IMAGE *m, double *entropy ) -{ - double *pbuf, *pbufstart; - double *cpbuf; - register int i,j; - double tmpent, dtemp; - double val; - - if( im_incheck( m ) ) - return( -1 ); - - if (m->Xsize != 256 || m->Ysize != 256 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) - { - im_error( "im_cooc_entropy", "%s", _( "unable to accept input") ); - return(-1); - } - pbufstart = (double*)m->data; - - tmpent = 0.0; - pbuf = pbufstart; - for(j=0; jYsize; j++) - { - cpbuf = pbuf; - pbuf += m->Xsize; - for(i=0; iXsize; i++) - { - if(*cpbuf != 0) - { - dtemp = *cpbuf; - tmpent += (dtemp*log10(dtemp)); - } - cpbuf++; - } - } - val = tmpent*(-1); - -#ifdef DEBUG - fprintf(stderr,"ENT=%f\nwhich is %f bits\n", val, val/log10(2.0) ); -#endif - *entropy = (val/log10(2.0)); - return(0); -} diff --git a/libvips/other/glds_funcs.c b/libvips/other/glds_funcs.c deleted file mode 100644 index 5a419a47..00000000 --- a/libvips/other/glds_funcs.c +++ /dev/null @@ -1,256 +0,0 @@ -/* @(#) Calculates the spatial grey level differnce - * @(#) matrix of an image and some of its - * @(#) features. The 256x1 difference matrix of im is held by m - * @(#) There should be enough margin around the box so the (dx,dy) can - * @(#) access neighbouring pixels outside the box - * @(#) - * @(#) Usage: - * @(#) int im_glds_matrix(im, m, xpos, ypos, xsize, ysize, dx, dy) - * @(#) IMAGE *im, *m; - * @(#) int xpos, ypos, xsize, ysize; location of the box within im - * @(#) int dx, dy; displacements - * @(#) - * @(#) int im_glds_asm(m, asmoment) - * @(#) IMAGE *m; - * @(#) double *asmoment; - * @(#) - * @(#) int im_glds_contrast(m, contrast) - * @(#) IMAGE *m; - * @(#) double *contrast; - * @(#) - * @(#) int im_glds_entropy(m, entropy) - * @(#) IMAGE *m; - * @(#) double *entropy; - * @(#) - * @(#) int im_glds_mean(m, mean) - * @(#) IMAGE *m; - * @(#) double *mean; - * @(#) - * @(#) All functions return 0 on success and -1 on error - * - * Copyright: N. Dessipris, 1991 - * Written on: 2/12/1991 - * Modified on: - * 22/7/93 JC - * - im_incheck() added - */ - -/* - - This file is part of VIPS. - - VIPS is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - */ - -/* - - These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk - - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /*HAVE_CONFIG_H*/ -#include - -#include -#include -#include - -#include - -#ifdef WITH_DMALLOC -#include -#endif /*WITH_DMALLOC*/ - -/* Keep the greylevel difference matrix as a 256x1 double image */ - -int -im_glds_matrix( IMAGE *im, IMAGE *m, - int xpos, int ypos, int xsize, int ysize, int dx, int dy ) -{ - PEL *in, *cpin; - int *b, *pb; - double *l, *pl; - int x, y; - int ofs; - int tmp; - int norm; - - if (im_iocheck(im, m) == -1) - return( -1 ); - - if ((im->Bands != 1)||(im->BandFmt != IM_BANDFMT_UCHAR)) { - im_error( "im_glds_matrix", "%s", _( "Wrong input") ); - return(-1); } - - if ( (xpos + xsize + dx > im->Xsize)|| (ypos + ysize + dy > im->Ysize) ) { - im_error( "im_glds_matrix", "%s", _( "wrong args") ); - return(-1); } - - if (im_cp_desc(m, im) == -1) - return( -1 ); - m->Xsize = 256; - m->Ysize = 1; - m->BandFmt = IM_BANDFMT_DOUBLE; - m->Type = IM_TYPE_B_W; - - if (im_setupout(m) == -1) - return( -1 ); - - b = (int *)calloc( (unsigned)m->Xsize, sizeof(int) ); - l = (double *)calloc( (unsigned)m->Xsize, sizeof(double)); - if ( (b == NULL) || (l == NULL) ) { - im_error( "im_glds_matrix", "%s", _( "calloc failed") ); - return(-1); } - - in = (PEL*)im->data; - in += ( ypos * im->Xsize + xpos ); - ofs = dy * im->Xsize + dx; - for ( y=0; yXsize; - for ( x=0; xXsize; x++) - *pl++ = ((double)(*pb++))/(double)norm; - if (im_writeline( 0, m, (PEL *) l ) == -1) - return( -1 ); - - free((char*)b); free((char*)l); - return(0); -} - -/* @(#) Calculates the asmoment of the sglds matrix held by m - */ -int -im_glds_asm( IMAGE *m, double *asmoment ) -{ - double temp, tmpasm, *in; - int i; - - if( im_incheck( m ) ) - return( -1 ); - - if (m->Xsize != 256 || m->Ysize != 1 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { - im_error( "im_glds_asm", "%s", _( "unable to accept input") ); - return(-1);} - tmpasm = 0.0; - in = (double*)m->data; - for(i=0; iXsize; i++) - { - temp = *in++; - tmpasm += (temp*temp); - } - *asmoment = tmpasm; - return(0); -} - -/* @(#) Calculates the contrast of the coocurence matrix passed in buffer - */ -int -im_glds_contrast( IMAGE *m, double *contrast ) -{ - double tmpcon, *in; - int i; - - if( im_incheck( m ) ) - return( -1 ); - - if (m->Xsize != 256 || m->Ysize != 1 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { - im_error( "im_glds_contrast", "%s", _( "wrong input") ); - return(-1); } - tmpcon = 0.0; - in = (double*)m->data; - for(i=0; iXsize; i++) - { - tmpcon += ( ((double)i)*((double)i)*(*in) ); - in++; - } - *contrast = tmpcon; - return(0); -} - -/* @(#) Calculates the entropy of the glds vector passed in buffer - * @(#) Function returns the entropy based on log base 2. - */ -int -im_glds_entropy( IMAGE *m, double *entropy ) -{ - double tmpent, dtemp, *in; - int i; - - if( im_incheck( m ) ) - return( -1 ); - - if (m->Xsize != 256 || m->Ysize != 1 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { - im_error( "im_glds_entropy", "%s", _( "wrong input") ); - return(-1); } - tmpent = 0.0; - in = (double*)m->data; - for(i=0; iXsize; i++) - { - if(*in != 0) - { - dtemp = *in; - tmpent += (dtemp*log10(dtemp)); - } - in++; - } - *entropy = ((-1)*tmpent/log10(2.0)); - return(0); -} - -/* @(#) Calculates the mean of the sglds matrix passed in m - */ -int -im_glds_mean( IMAGE *m, double *mean ) -{ - double tmpmean, *in; - int i; - - if( im_incheck( m ) ) - return( -1 ); - - if (m->Xsize != 256 || m->Ysize != 1 || - m->Bands != 1 || m->BandFmt != IM_BANDFMT_DOUBLE) { - im_error( "im_glds_mean", "%s", _( "wrong input") ); - return(-1); } - tmpmean = 0.0; - in = (double*)m->data; - for(i=0; iXsize; i++) - { - tmpmean += ( ((double)i)*(*in) ); - in++; - } - tmpmean = tmpmean/((double)m->Xsize); - *mean = tmpmean; - return(0); -} diff --git a/libvips/other/im_benchmark.c b/libvips/other/im_benchmark.c index 0022fdf5..5e015650 100644 --- a/libvips/other/im_benchmark.c +++ b/libvips/other/im_benchmark.c @@ -1,18 +1,11 @@ -/* @(#) Do a complicated compound operation for benchmarking the threading - * @(#) system. Input should be a large LABQ image, output is a large sRGB - * @(#) image. - * @(#) - * @(#) Usage: - * @(#) - * @(#) int im_benchmark( IMAGE *in, IMAGE *out ) - * @(#) - * @(#) Returns 0 on sucess and -1 on error. - * @(#) +/* a complicated operation for testing * * 6/10/06 * - hacked in * 27/11/06 * - added im_benchmarkn() + * 1/2/11 + * - gtk-doc */ /* @@ -244,7 +237,23 @@ benchmark( IMAGE *in, IMAGE *out ) ); } -/* Chain n benchmarks together to get a CPU-bound operation. +/** + * im_benchmarkn: + * @in: input image + * @out: output image + * @n: iterations + * + * This operation runs a complicated set of other operations on image @in, + * producing image @out. Use @n to set the number of iterations to run: a + * larger number will make the operation more CPU-bound, a smaller number will + * make the operation more IO-bound. + * + * See http://www.vips.ecs.soton.ac.uk/index.php?title=Benchmarks for a + * detailed discussion of the benchmark and some sample results. + * + * See also: im_benchmark2(). + * + * Returns: 0 on success, -1 on error */ int im_benchmarkn( IMAGE *in, IMAGE *out, int n ) @@ -274,6 +283,18 @@ im_benchmarkn( IMAGE *in, IMAGE *out, int n ) im_benchmarkn( t[1], out, n - 1 ) ); } +/** + * im_benchmark2: + * @in: input image + * @out: average image value + * + * This operation runs a single im_benchmarkn() and calculates the average + * pixel value. It's useful if you just want to test image input. + * + * See also: im_benchmarkn(). + * + * Returns: 0 on success, -1 on error + */ int im_benchmark2( IMAGE *in, double *out ) { diff --git a/libvips/other/im_meanstd.c b/libvips/other/im_meanstd.c deleted file mode 100644 index df14994b..00000000 --- a/libvips/other/im_meanstd.c +++ /dev/null @@ -1,136 +0,0 @@ -/* @(#) Calculates the mean and the standard deviation (std) of - * @(#) an int or double buffer of size size. - * @(#) - * @(#) Usage: - * @(#) int im__mean_std_double_buffer(buffer, size, pmean, pstd) - * @(#) double *buffer; - * @(#) int size; - * @(#) double *pmean, *pstd; - * @(#) - * @(#) int im__mean_std_int_buffer(buffer, size, pmean, pstd) - * @(#) int *buffer; - * @(#) int size; - * @(#) double *pmean, *pstd; - * @(#) - * @(#) Both functions return 0 on success and -1 on error - * - * Copyright: N. Dessipris 1991 - * Written on: 2/12/1991 - * Updated on: 2/12/1991 - * 22/7/93 JC - * - externs removed - */ - -/* - - This file is part of VIPS. - - VIPS is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - */ - -/* - - These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk - - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /*HAVE_CONFIG_H*/ -#include - -#include -#include -#include - -#include - -#ifdef WITH_DMALLOC -#include -#endif /*WITH_DMALLOC*/ - -int -im__mean_std_double_buffer( double *buffer, int size, - double *pmean, double *pstd ) -{ - double mean, std; - register int i; - double sumf; - double temp; - double *pbuffer; - double sumf2; - double correction; /* calulates the correction term for the variance */ - double variance; /* = (sumf2 - correction)/n */ - - if (size <= 0) { - im_error( "im_mean_std_double_buffer", "%s", _( "wrong args") ); - return(-1); - } - mean = 0.0; std = 0.0; - sumf = 0.0; sumf2 = 0.0; - pbuffer = buffer; - for (i=0; i