static int vips_histogram_build( VipsObject *object ) { VipsHistogram *histogram = VIPS_HISTOGRAM( object ); #ifdef DEBUG printf( "vips_histogram_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ g_object_set( histogram, "out", vips_image_new(), NULL ); if( VIPS_OBJECT_CLASS( vips_histogram_parent_class )->build( object ) ) return( -1 ); return( 0 ); }
* manipulate histograms in some way (im_histcum(), im_histnorm()), operations * to apply histograms (im_maplut()), and a variety of utility * operations. * * A final group of operations build tone curves. These are useful in * pre-press work for adjusting the appearance of images. They are designed * for CIELAB images, but might be useful elsewhere. */ G_DEFINE_ABSTRACT_TYPE( VipsHistogram, vips_histogram, VIPS_TYPE_OPERATION ); static int vips_histogram_build( VipsObject *object ) { VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); VipsHistogram *histogram = VIPS_HISTOGRAM( object ); #ifdef DEBUG printf( "vips_histogram_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ g_object_set( histogram, "out", vips_image_new(), NULL ); if( VIPS_OBJECT_CLASS( vips_histogram_parent_class )->build( object ) ) return( -1 ); if( vips_check_hist( class->nickname, histogram->in ) ) return( -1 );
static int vips_histogram_build( VipsObject *object ) { VipsHistogram *histogram = VIPS_HISTOGRAM( object ); VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); VipsHistogramClass *hclass = VIPS_HISTOGRAM_GET_CLASS( histogram ); VipsImage **decode; VipsImage **format; VipsImage **band; VipsImage **size; VipsImage **memory; VipsPel *outbuf; VipsPel **inbuf; int i; #ifdef DEBUG printf( "vips_histogram_build: " ); vips_object_print_name( object ); printf( "\n" ); #endif /*DEBUG*/ if( VIPS_OBJECT_CLASS( vips_histogram_parent_class )->build( object ) ) return( -1 ); g_assert( histogram->n > 0 ); /* Must be NULL-terminated. */ g_assert( !histogram->in[histogram->n] ); decode = (VipsImage **) vips_object_local_array( object, histogram->n ); format = (VipsImage **) vips_object_local_array( object, histogram->n ); band = (VipsImage **) vips_object_local_array( object, histogram->n ); size = (VipsImage **) vips_object_local_array( object, histogram->n ); memory = (VipsImage **) vips_object_local_array( object, histogram->n ); g_object_set( histogram, "out", vips_image_new(), NULL ); for( i = 0; i < histogram->n; i++ ) if( vips_image_decode( histogram->in[i], &decode[i] ) || vips_check_hist( class->nickname, decode[i] ) ) return( -1 ); /* Cast our input images up to a common format, bands and size. If * input_format is set, cast to a fixed input type. */ if( hclass->input_format != VIPS_FORMAT_NOTSET ) { for( i = 0; i < histogram->n; i++ ) if( vips_cast( decode[i], &format[i], hclass->input_format, NULL ) ) return( -1 ); } else { if( vips__formatalike_vec( decode, format, histogram->n ) ) return( -1 ); } if( vips__bandalike_vec( class->nickname, format, band, histogram->n, 1 ) || vips__hist_sizealike_vec( band, size, histogram->n ) ) return( -1 ); if( vips_image_pipeline_array( histogram->out, VIPS_DEMAND_STYLE_THINSTRIP, size ) ) return( -1 ); /* Need a copy of the inputs in memory. */ if( !(inbuf = VIPS_ARRAY( object, histogram->n + 1, VipsPel * )) ) return( -1 ); for( i = 0; i < histogram->n; i++ ) { if( !(memory[i] = vips_image_copy_memory( size[i] )) ) return( -1 ); inbuf[i] = VIPS_IMAGE_ADDR( memory[i], 0, 0 ); } inbuf[i] = NULL; /* Keep a copy of the memory images here for subclasses. */ histogram->ready = memory; histogram->out->Xsize = VIPS_IMAGE_N_PELS( histogram->ready[0] ); histogram->out->Ysize = 1; if( hclass->format_table ) histogram->out->BandFmt = hclass->format_table[histogram->ready[0]->BandFmt]; histogram->out->Type = VIPS_INTERPRETATION_HISTOGRAM; if( !(outbuf = vips_malloc( object, VIPS_IMAGE_SIZEOF_LINE( histogram->out ))) ) return( -1 ); hclass->process( histogram, outbuf, inbuf, histogram->ready[0]->Xsize ); if( vips_image_write_line( histogram->out, 0, outbuf ) ) return( -1 ); return( 0 ); }