fix hist normalisation

hist norm was broken due to the VipsStats width change
This commit is contained in:
John Cupitt 2012-02-28 12:05:25 +00:00
parent ef19ecc923
commit 6ba96b2333
7 changed files with 27 additions and 9 deletions

5
TODO
View File

@ -1,6 +1,11 @@
blocking bugs
=============
- hist norm broken?
hist match broken?
- none!

View File

@ -78,8 +78,8 @@ im_scale( IMAGE *in, IMAGE *out )
*/
if( !t || !(stats = im_stats( in )) )
return( -1 );
mn = stats->coeff[0];
mx = stats->coeff[1];
mn = VIPS_MASK( stats, 0, 0 );
mx = VIPS_MASK( stats, 1, 0 );
im_free_dmask( stats );
if( mn == mx )

View File

@ -162,7 +162,7 @@ im_histnorm( IMAGE *in, IMAGE *out )
const guint64 px = VIPS_IMAGE_N_PELS( in );
DOUBLEMASK *stats;
double *a, *b;
int i;
int y;
IMAGE *t1;
int fmt;
@ -175,9 +175,9 @@ im_histnorm( IMAGE *in, IMAGE *out )
/* Scale each channel by px / channel max
*/
for( i = 0; i < in->Bands; i++ ) {
a[i] = px / stats->coeff[6 + 1 + 6*i];
b[i] = 0;
for( y = 0; y < in->Bands; y++ ) {
a[y] = px / VIPS_MASK( stats, 1, y + 1 );
b[y] = 0;
}
im_free_dmask( stats );

View File

@ -105,8 +105,8 @@ normalise( IMAGE *in, IMAGE *out )
if( !(stats = im_stats( in )) )
return( -1 );
min = stats->coeff[0];
max = stats->coeff[1];
min = VIPS_MASK( stats, 0, 0 );
max = VIPS_MASK( stats, 1, 0 );
im_free_dmask( stats );
if( !(t1 = im_open_local( out, "im_histplot", "p" )) ||

View File

@ -55,6 +55,8 @@ typedef struct im__DOUBLEMASK {
char *filename;
} DOUBLEMASK;
#define VIPS_MASK( M, X, Y ) ((M)->coeff[(X) + (Y) * (M)->xsize])
INTMASK *im_create_imask( const char *filename, int xsize, int ysize );
INTMASK *im_create_imaskv( const char *filename, int xsize, int ysize, ... );
DOUBLEMASK *im_create_dmask( const char *filename, int xsize, int ysize );

View File

@ -6,7 +6,6 @@ logging.basicConfig(level = logging.DEBUG)
from vips8 import vips
from gi.repository import Vips
Vips.cache_set_trace(True)
try:

12
python/try3.py Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/python
import sys
from vips8 import vips
from gi.repository import Vips
Vips.cache_set_trace(True)
a = vips.Image(sys.argv[1])
print a.max()
print a.max()