This commit is contained in:
John Cupitt 2007-10-22 10:55:52 +00:00
parent 20d83b9af2
commit 5415dd700c
12 changed files with 104 additions and 67 deletions

View File

@ -1,8 +1,8 @@
28/9/07 started 7.13.1
- vips2dj can print RGB images
- oop, include <stdexcept> missing
- add protos for generate/iterate function args, started fixing warnings
- add cimg package
- add protos for generate/iterate function args, fix warnings
- add cimg package, we now have C++ source inside VIPS, sigh
29/8/07 started 7.13.0
- we now have a trunk and the version is 7.13.x, woo!

View File

@ -217,6 +217,10 @@ int im_grad_x( IMAGE *in, IMAGE *out ){
#endif
#undef RETURN_GENERATE
}
/* Keep gcc happy.
*/
return 0;
#undef FUNCTION_NAME
}
@ -277,6 +281,10 @@ int im_grad_y( IMAGE *in, IMAGE *out ){
#endif
#undef RETURN_GENERATE
}
/* Keep gcc happy.
*/
return 0;
#undef FUNCTION_NAME
}

View File

@ -84,7 +84,7 @@ zerox_gen( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
IMAGE *in = (IMAGE *) a;
int flag = (int) b;
int flag = GPOINTER_TO_INT( b );
Rect irect;
Rect *r = &or->valid;

View File

@ -109,8 +109,10 @@ build_hist( IMAGE *out, int bands, int which, int size )
/* Build a sub-hist, based on the main hist.
*/
static void *
build_subhist( IMAGE *out, Histogram *mhist )
build_subhist( IMAGE *out, void *a, void *b )
{
Histogram *mhist = (Histogram *) a;
return( (void *)
build_hist( out, mhist->bands, mhist->which, mhist->size ) );
}
@ -118,8 +120,10 @@ build_subhist( IMAGE *out, Histogram *mhist )
/* Join a sub-hist onto the main hist.
*/
static int
merge_subhist( Histogram *shist, Histogram *mhist )
merge_subhist( void *seq, void *a, void *b )
{
Histogram *shist = (Histogram *) seq;
Histogram *mhist = (Histogram *) a;
int i, j;
/* Sanity!
@ -146,8 +150,9 @@ merge_subhist( Histogram *shist, Histogram *mhist )
/* Histogram of all bands of a uchar image.
*/
static int
find_uchar_hist( REGION *reg, Histogram *hist )
find_uchar_hist( REGION *reg, void *seq, void *a, void *b )
{
Histogram *hist = (Histogram *) seq;
Rect *r = &reg->valid;
IMAGE *im = reg->im;
int le = r->left;
@ -177,8 +182,9 @@ find_uchar_hist( REGION *reg, Histogram *hist )
/* Histogram of a selected band of a uchar image.
*/
static int
find_uchar_hist_extract( REGION *reg, Histogram *hist )
find_uchar_hist_extract( REGION *reg, void *seq, void *a, void *b )
{
Histogram *hist = (Histogram *) seq;
Rect *r = &reg->valid;
IMAGE *im = reg->im;
int le = r->left;
@ -208,8 +214,9 @@ find_uchar_hist_extract( REGION *reg, Histogram *hist )
/* Histogram of all bands of a ushort image.
*/
static int
find_ushort_hist( REGION *reg, Histogram *hist )
find_ushort_hist( REGION *reg, void *seq, void *a, void *b )
{
Histogram *hist = (Histogram *) seq;
Rect *r = &reg->valid;
IMAGE *im = reg->im;
int le = r->left;
@ -249,8 +256,9 @@ find_ushort_hist( REGION *reg, Histogram *hist )
/* Histogram of all bands of a ushort image.
*/
static int
find_ushort_hist_extract( REGION *reg, Histogram *hist )
find_ushort_hist_extract( REGION *reg, void *seq, void *a, void *b )
{
Histogram *hist = (Histogram *) seq;
Rect *r = &reg->valid;
IMAGE *im = reg->im;
int le = r->left;
@ -293,7 +301,7 @@ im_histgr( IMAGE *in, IMAGE *out, int bandno )
int size; /* Length of hist */
int bands; /* Number of bands in output */
Histogram *mhist;
int (*scanfn)( REGION *, Histogram * );
im_generate_fn scanfn;
int i, j;
unsigned int *obuffer, *q;

View File

@ -109,8 +109,10 @@ build_hist( IMAGE *in, IMAGE *out, int bins )
/* Build a sub-hist, based on the main hist.
*/
static void *
build_subhist( IMAGE *out, Histogram *mhist )
build_subhist( IMAGE *out, void *a, void *b )
{
Histogram *mhist = (Histogram *) a;
return( (void *)
build_hist( mhist->in, mhist->out, mhist->bins ) );
}
@ -118,8 +120,10 @@ build_subhist( IMAGE *out, Histogram *mhist )
/* Join a sub-hist onto the main hist.
*/
static int
merge_subhist( Histogram *shist, Histogram *mhist )
merge_subhist( void *seq, void *a, void *b )
{
Histogram *shist = (Histogram *) seq;
Histogram *mhist = (Histogram *) a;
int i, j, k;
/* Sanity!
@ -157,8 +161,9 @@ merge_subhist( Histogram *shist, Histogram *mhist )
}
static int
find_hist( REGION *reg, Histogram *hist )
find_hist( REGION *reg, void *seq, void *a, void *b )
{
Histogram *hist = (Histogram *) seq;
Rect *r = &reg->valid;
IMAGE *im = reg->im;
int le = r->left;

View File

@ -144,8 +144,8 @@ normalise( IMAGE *in, IMAGE *out )
TYPE *p1 = (TYPE *) p; \
\
for( x = le; x < ri; x++ ) { \
for( b = 0; b < nb; b++ ) \
q[b] = p1[b] < x ? 0 : 255; \
for( z = 0; z < nb; z++ ) \
q[z] = p1[z] < x ? 0 : 255; \
\
q += nb; \
} \
@ -155,8 +155,9 @@ normalise( IMAGE *in, IMAGE *out )
/* Generate function.
*/
static int
make_vert_gen( REGION *or, void *dummy, IMAGE *in )
make_vert_gen( REGION *or, void *seq, void *a, void *b )
{
IMAGE *in = (IMAGE *) a;
Rect *r = &or->valid;
int le = r->left;
int to = r->top;
@ -164,7 +165,7 @@ make_vert_gen( REGION *or, void *dummy, IMAGE *in )
int bo = IM_RECT_BOTTOM( r );
int nb = in->Bands;
int x, y, b;
int x, y, z;
for( y = to; y < bo; y++ ) {
unsigned char *q = (unsigned char *)
@ -195,8 +196,8 @@ make_vert_gen( REGION *or, void *dummy, IMAGE *in )
TYPE *p1 = (TYPE *) p; \
\
for( y = to; y < bo; y++ ) { \
for( b = 0; b < nb; b++ ) \
q[b] = p1[b] < (ht - y) ? 0 : 255; \
for( z = 0; z < nb; z++ ) \
q[z] = p1[z] < (ht - y) ? 0 : 255; \
\
q += lsk; \
} \
@ -206,8 +207,9 @@ make_vert_gen( REGION *or, void *dummy, IMAGE *in )
/* Generate function.
*/
static int
make_horz_gen( REGION *or, void *dummy, IMAGE *in )
make_horz_gen( REGION *or, void *seq, void *a, void *b )
{
IMAGE *in = (IMAGE *) a;
Rect *r = &or->valid;
int le = r->left;
int to = r->top;
@ -217,7 +219,7 @@ make_horz_gen( REGION *or, void *dummy, IMAGE *in )
int lsk = IM_REGION_LSKIP( or );
int ht = or->im->Ysize;
int x, y, b;
int x, y, z;
for( x = le; x < ri; x++ ) {
unsigned char *q = (unsigned char *)

View File

@ -74,8 +74,10 @@ typedef struct {
/* lhist generate function.
*/
static int
lhist_gen( REGION *or, REGION *ir, IMAGE *in, LhistInfo *inf )
lhist_gen( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
LhistInfo *inf = (LhistInfo *) inf;
Rect irect;
Rect *r = &or->valid;

View File

@ -173,16 +173,16 @@ typedef struct {
/* Destroy a sequence value.
*/
static int
stop_maplut( Seq *seq, IMAGE *in, LutInfo *st )
maplut_stop( void *vseq, void *a, void *b )
{
Seq *seq = (Seq *) vseq;
LutInfo *st = (LutInfo *) b;
/* Add to global stats.
*/
st->overflow += seq->overflow;
if( seq->ir ) {
im_region_free( seq->ir );
seq->ir = NULL;
}
IM_FREEF( im_region_free, seq->ir );
return( 0 );
}
@ -190,11 +190,12 @@ stop_maplut( Seq *seq, IMAGE *in, LutInfo *st )
/* Our start function.
*/
static void *
start_maplut( IMAGE *out, IMAGE *in, LutInfo *st )
maplut_start( IMAGE *out, void *a, void *b )
{
Seq *seq = IM_NEW( out, Seq );
if( !seq )
IMAGE *in = (IMAGE *) a;
Seq *seq;
if( !(seq = IM_NEW( out, Seq )) )
return( NULL );
/* Init!
@ -205,7 +206,7 @@ start_maplut( IMAGE *out, IMAGE *in, LutInfo *st )
if( !(seq->ir = im_region_create( in )) )
return( NULL );
return( (void *) seq );
return( seq );
}
/* Map through n non-complex luts.
@ -508,8 +509,11 @@ start_maplut( IMAGE *out, IMAGE *in, LutInfo *st )
/* Do a map.
*/
static int
gen_map( REGION *or, Seq *seq, IMAGE *in, LutInfo *st )
maplut_gen( REGION *or, void *vseq, void *a, void *b )
{
Seq *seq = (Seq *) vseq;
IMAGE *in = (IMAGE *) a;
LutInfo *st = (LutInfo *) b;
REGION *ir = seq->ir;
Rect *r = &or->valid;
int le = r->left;
@ -616,7 +620,7 @@ im_maplut( IMAGE *in, IMAGE *out, IMAGE *lut )
/* Process!
*/
if( im_generate( out, start_maplut, gen_map, stop_maplut, in, st ) )
if( im_generate( out, maplut_start, maplut_gen, maplut_stop, in, st ) )
return( -1 );
return( 0 );

View File

@ -104,10 +104,11 @@ project_new( IMAGE *in, IMAGE *hout, IMAGE *vout )
/* Build a sub-project, based on the main project.
*/
static void *
project_new_sub( IMAGE *out, Project *mproject )
project_new_sub( IMAGE *out, void *a, void *b )
{
return( (void *)
project_new( mproject->in, mproject->hout, mproject->vout ) );
Project *mproject = (Project *) a;
return( project_new( mproject->in, mproject->hout, mproject->vout ) );
}
#define ADD_BUFFER( TYPE, Q, P, N ) { \
@ -123,8 +124,10 @@ project_new_sub( IMAGE *out, Project *mproject )
/* Join a sub-project onto the main project.
*/
static int
project_merge( Project *sproject, Project *mproject )
project_merge( void *seq, void *a, void *b )
{
Project *sproject = (Project *) seq;
Project *mproject = (Project *) a;
IMAGE *in = mproject->in;
IMAGE *out = mproject->hout;
int hsz = in->Xsize * in->Bands;
@ -192,8 +195,9 @@ project_merge( Project *sproject, Project *mproject )
/* Add a region to a project.
*/
static int
project_scan( REGION *reg, Project *project )
project_scan( REGION *reg, void *seq, void *a, void *b )
{
Project *project = (Project *) seq;
Rect *r = &reg->valid;
int le = r->left;
int to = r->top;

View File

@ -91,8 +91,10 @@ typedef struct {
/* stdif generate function.
*/
static int
stdif_gen( REGION *or, REGION *ir, IMAGE *in, StdifInfo *inf )
stdif_gen( REGION *or, void *seq, void *a, void *b )
{
REGION *ir = (REGION *) seq;
StdifInfo *inf = (StdifInfo *) b;
Rect irect;
Rect *r = &or->valid;

View File

@ -76,14 +76,11 @@ typedef struct {
/* Stop function.
*/
static int
stop_dilate( SeqInfo *seq, IMAGE *in )
dilate_stop( void *vseq, void *a, void *b )
{
/* Free attached objects.
*/
if( seq->ir ) {
im_region_free( seq->ir );
seq->ir = NULL;
}
SeqInfo *seq = (SeqInfo *) vseq;
IM_FREEF( im_region_free, seq->ir );
return( 0 );
}
@ -91,12 +88,14 @@ stop_dilate( SeqInfo *seq, IMAGE *in )
/* Start function.
*/
static void *
start_dilate( IMAGE *out, IMAGE *in, INTMASK *msk )
dilate_start( IMAGE *out, void *a, void *b )
{
SeqInfo *seq = IM_NEW( out, SeqInfo );
IMAGE *in = (IMAGE *) a;
INTMASK *msk = (INTMASK *) b;
int sz = msk->xsize * msk->ysize;
SeqInfo *seq;
if( !seq )
if( !(seq = IM_NEW( out, SeqInfo )) )
return( NULL );
/* Init!
@ -113,18 +112,20 @@ start_dilate( IMAGE *out, IMAGE *in, INTMASK *msk )
seq->soff = IM_ARRAY( out, sz, int );
seq->coff = IM_ARRAY( out, sz, int );
if( !seq->ir || !seq->soff || !seq->coff ) {
stop_dilate( seq, in );
dilate_stop( seq, in, NULL );
return( NULL );
}
return( (void *) seq );
return( seq );
}
/* Dilate!
*/
static int
gen_dilate( REGION *or, SeqInfo *seq, IMAGE *in, INTMASK *msk )
dilate_gen( REGION *or, void *vseq, void *a, void *b )
{
SeqInfo *seq = (SeqInfo *) vseq;
INTMASK *msk = (INTMASK *) b;
REGION *ir = seq->ir;
int *soff = seq->soff;
@ -283,7 +284,7 @@ im_dilate_raw( IMAGE *in, IMAGE *out, INTMASK *m )
/* Generate!
*/
if( im_generate( out, start_dilate, gen_dilate, stop_dilate, in, msk ) )
if( im_generate( out, dilate_start, dilate_gen, dilate_stop, in, msk ) )
return( -1 );
out->Xoffset = -m->xsize / 2;

View File

@ -76,14 +76,11 @@ typedef struct {
/* Stop function.
*/
static int
stop_erode( SeqInfo *seq, IMAGE *in )
erode_stop( void *vseq, void *a, void *b )
{
/* Free attached objects.
*/
if( seq->ir ) {
im_region_free( seq->ir );
seq->ir = NULL;
}
SeqInfo *seq = (SeqInfo *) vseq;
IM_FREEF( im_region_free, seq->ir );
return( 0 );
}
@ -91,12 +88,14 @@ stop_erode( SeqInfo *seq, IMAGE *in )
/* Start function.
*/
static void *
start_erode( IMAGE *out, IMAGE *in, INTMASK *msk )
erode_start( IMAGE *out, void *a, void *b )
{
SeqInfo *seq = IM_NEW( out, SeqInfo );
IMAGE *in = (IMAGE *) a;
INTMASK *msk = (INTMASK *) b;
SeqInfo *seq;
int sz = msk->xsize * msk->ysize;
if( !seq )
if( !(seq = IM_NEW( out, SeqInfo )) )
return( NULL );
/* Init!
@ -113,7 +112,7 @@ start_erode( IMAGE *out, IMAGE *in, INTMASK *msk )
seq->soff = IM_ARRAY( out, sz, int );
seq->coff = IM_ARRAY( out, sz, int );
if( !seq->ir || !seq->soff || !seq->coff ) {
stop_erode( seq, in );
erode_stop( seq, in, NULL );
return( NULL );
}
@ -123,8 +122,10 @@ start_erode( IMAGE *out, IMAGE *in, INTMASK *msk )
/* Erode!
*/
static int
gen_erode( REGION *or, SeqInfo *seq, IMAGE *in, INTMASK *msk )
erode_gen( REGION *or, void *vseq, void *a, void *b )
{
SeqInfo *seq = (SeqInfo *) vseq;
INTMASK *msk = (INTMASK *) b;
REGION *ir = seq->ir;
int *soff = seq->soff;
@ -281,7 +282,7 @@ im_erode_raw( IMAGE *in, IMAGE *out, INTMASK *m )
/* Generate!
*/
if( im_generate( out, start_erode, gen_erode, stop_erode, in, msk ) )
if( im_generate( out, erode_start, erode_gen, erode_stop, in, msk ) )
return( -1 );
out->Xoffset = -m->xsize / 2;