From 8259da2b9c91be97b21c264af76964a79dbb0ad1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 1 Jul 2013 13:45:36 +0100 Subject: [PATCH] getting ready to rewrite hist stuff --- ChangeLog | 2 + configure.ac | 10 +- libvips/Makefile.am | 4 +- .../{histograms_lut => histogram}/Makefile.am | 4 +- .../hist_dispatch.c | 0 libvips/histogram/histogram.c | 131 ++++++++++++++++++ .../im_buildlut.c | 0 .../im_gammacorrect.c | 0 .../{histograms_lut => histogram}/im_heq.c | 0 .../{histograms_lut => histogram}/im_hist.c | 0 .../{histograms_lut => histogram}/im_histeq.c | 0 .../{histograms_lut => histogram}/im_histgr.c | 0 .../im_histindexed.c | 0 .../{histograms_lut => histogram}/im_histnD.c | 0 .../im_histplot.c | 0 .../im_histspec.c | 0 .../{histograms_lut => histogram}/im_hsp.c | 0 .../im_identity.c | 0 .../im_invertlut.c | 0 .../im_lhisteq.c | 0 .../{histograms_lut => histogram}/im_maplut.c | 0 .../im_mpercent.c | 0 .../im_project.c | 0 .../{histograms_lut => histogram}/im_stdif.c | 0 libvips/histogram/phistogram.h | 77 ++++++++++ libvips/{histograms_lut => histogram}/tone.c | 0 26 files changed, 219 insertions(+), 9 deletions(-) rename libvips/{histograms_lut => histogram}/Makefile.am (83%) rename libvips/{histograms_lut => histogram}/hist_dispatch.c (100%) create mode 100644 libvips/histogram/histogram.c rename libvips/{histograms_lut => histogram}/im_buildlut.c (100%) rename libvips/{histograms_lut => histogram}/im_gammacorrect.c (100%) rename libvips/{histograms_lut => histogram}/im_heq.c (100%) rename libvips/{histograms_lut => histogram}/im_hist.c (100%) rename libvips/{histograms_lut => histogram}/im_histeq.c (100%) rename libvips/{histograms_lut => histogram}/im_histgr.c (100%) rename libvips/{histograms_lut => histogram}/im_histindexed.c (100%) rename libvips/{histograms_lut => histogram}/im_histnD.c (100%) rename libvips/{histograms_lut => histogram}/im_histplot.c (100%) rename libvips/{histograms_lut => histogram}/im_histspec.c (100%) rename libvips/{histograms_lut => histogram}/im_hsp.c (100%) rename libvips/{histograms_lut => histogram}/im_identity.c (100%) rename libvips/{histograms_lut => histogram}/im_invertlut.c (100%) rename libvips/{histograms_lut => histogram}/im_lhisteq.c (100%) rename libvips/{histograms_lut => histogram}/im_maplut.c (100%) rename libvips/{histograms_lut => histogram}/im_mpercent.c (100%) rename libvips/{histograms_lut => histogram}/im_project.c (100%) rename libvips/{histograms_lut => histogram}/im_stdif.c (100%) create mode 100644 libvips/histogram/phistogram.h rename libvips/{histograms_lut => histogram}/tone.c (100%) diff --git a/ChangeLog b/ChangeLog index ec4b047a..17293d99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +1/7/13 started 7.35.0 + 28/6/13 started 7.34.1 - fix morphological operators on non-uchar images - remove any ICC profile when we use vips to go to srgb diff --git a/configure.ac b/configure.ac index 18ba33c3..a672c99e 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [7.34.1], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [7.35.0], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -16,8 +16,8 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [7]) -m4_define([vips_minor_version], [34]) -m4_define([vips_micro_version], [1]) +m4_define([vips_minor_version], [35]) +m4_define([vips_micro_version], [0]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -37,7 +37,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date` # binary interface changes not backwards compatible?: reset age to 0 LIBRARY_CURRENT=34 -LIBRARY_REVISION=4 +LIBRARY_REVISION=5 LIBRARY_AGE=3 # patched into include/vips/version.h @@ -710,7 +710,7 @@ AC_OUTPUT([ libvips/deprecated/Makefile libvips/foreign/Makefile libvips/freq_filt/Makefile - libvips/histograms_lut/Makefile + libvips/histogram/Makefile libvips/inplace/Makefile libvips/iofuncs/Makefile libvips/morphology/Makefile diff --git a/libvips/Makefile.am b/libvips/Makefile.am index 1a39c082..a6f7b56a 100644 --- a/libvips/Makefile.am +++ b/libvips/Makefile.am @@ -20,7 +20,7 @@ SUBDIRS = \ convolution \ $(C_COMPILE_DIR) \ freq_filt \ - histograms_lut \ + histogram \ inplace \ iofuncs \ morphology \ @@ -53,7 +53,7 @@ libvips_la_LIBADD = \ $(C_LIB) \ foreign/libforeign.la \ freq_filt/libfreq_filt.la \ - histograms_lut/libhistograms_lut.la \ + histogram/libhistogram.la \ inplace/libinplace.la \ iofuncs/libiofuncs.la \ morphology/libmorphology.la \ diff --git a/libvips/histograms_lut/Makefile.am b/libvips/histogram/Makefile.am similarity index 83% rename from libvips/histograms_lut/Makefile.am rename to libvips/histogram/Makefile.am index 179a162c..a5015c2d 100644 --- a/libvips/histograms_lut/Makefile.am +++ b/libvips/histogram/Makefile.am @@ -1,6 +1,6 @@ -noinst_LTLIBRARIES = libhistograms_lut.la +noinst_LTLIBRARIES = libhistogram.la -libhistograms_lut_la_SOURCES = \ +libhistogram_la_SOURCES = \ hist_dispatch.c \ im_gammacorrect.c \ im_heq.c \ diff --git a/libvips/histograms_lut/hist_dispatch.c b/libvips/histogram/hist_dispatch.c similarity index 100% rename from libvips/histograms_lut/hist_dispatch.c rename to libvips/histogram/hist_dispatch.c diff --git a/libvips/histogram/histogram.c b/libvips/histogram/histogram.c new file mode 100644 index 00000000..8906d7ec --- /dev/null +++ b/libvips/histogram/histogram.c @@ -0,0 +1,131 @@ +/* base class for all histogram operations + * + * properties: + * - single output image + */ + +/* + + Copyright (C) 1991-2005 The National Gallery + + This library 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.1 of the License, or (at your option) any later version. + + This library 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 library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +/* +#define DEBUG + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include +#include +#include + +#include +#include + +#include "phistogram.h" + +/** + * SECTION: histogram + * @short_description: find, manipulate and apply histograms and lookup tables + * @stability: Stable + * @see_also: image + * @include: vips/vips.h + * + * Histograms and look-up tables are 1xn or nx1 images, where n is less than + * 256 or less than 65536, corresponding to 8- and 16-bit unsigned int images. + * They are + * tagged with a #VipsType of IM_TYPE_HISTOGRAM and usually displayed by + * user-interfaces such as nip2 as plots rather than images. + * + * These functions can be broadly grouped as things to find or build + * histograms (im_histgr(), im_buildlut(), in_identity()), operations that + * 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 ) +{ + 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 ); +} + +static void +vips_histogram_class_init( VipsHistogramClass *class ) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS( class ); + VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class ); + + gobject_class->set_property = vips_object_set_property; + gobject_class->get_property = vips_object_get_property; + + vobject_class->nickname = "histogram"; + vobject_class->description = _( "histogram operations" ); + vobject_class->build = vips_histogram_build; + + VIPS_ARG_IMAGE( class, "out", 1, + _( "Output" ), + _( "Output image" ), + VIPS_ARGUMENT_REQUIRED_OUTPUT, + G_STRUCT_OFFSET( VipsHistogram, out ) ); +} + +static void +vips_histogram_init( VipsHistogram *histogram ) +{ +} + +/* Called from iofuncs to init all operations in this dir. Use a plugin system + * instead? + */ +void +vips_histogram_operation_init( void ) +{ + extern GType vips_xyz_get_type( void ); + + vips_xyz_get_type(); +} diff --git a/libvips/histograms_lut/im_buildlut.c b/libvips/histogram/im_buildlut.c similarity index 100% rename from libvips/histograms_lut/im_buildlut.c rename to libvips/histogram/im_buildlut.c diff --git a/libvips/histograms_lut/im_gammacorrect.c b/libvips/histogram/im_gammacorrect.c similarity index 100% rename from libvips/histograms_lut/im_gammacorrect.c rename to libvips/histogram/im_gammacorrect.c diff --git a/libvips/histograms_lut/im_heq.c b/libvips/histogram/im_heq.c similarity index 100% rename from libvips/histograms_lut/im_heq.c rename to libvips/histogram/im_heq.c diff --git a/libvips/histograms_lut/im_hist.c b/libvips/histogram/im_hist.c similarity index 100% rename from libvips/histograms_lut/im_hist.c rename to libvips/histogram/im_hist.c diff --git a/libvips/histograms_lut/im_histeq.c b/libvips/histogram/im_histeq.c similarity index 100% rename from libvips/histograms_lut/im_histeq.c rename to libvips/histogram/im_histeq.c diff --git a/libvips/histograms_lut/im_histgr.c b/libvips/histogram/im_histgr.c similarity index 100% rename from libvips/histograms_lut/im_histgr.c rename to libvips/histogram/im_histgr.c diff --git a/libvips/histograms_lut/im_histindexed.c b/libvips/histogram/im_histindexed.c similarity index 100% rename from libvips/histograms_lut/im_histindexed.c rename to libvips/histogram/im_histindexed.c diff --git a/libvips/histograms_lut/im_histnD.c b/libvips/histogram/im_histnD.c similarity index 100% rename from libvips/histograms_lut/im_histnD.c rename to libvips/histogram/im_histnD.c diff --git a/libvips/histograms_lut/im_histplot.c b/libvips/histogram/im_histplot.c similarity index 100% rename from libvips/histograms_lut/im_histplot.c rename to libvips/histogram/im_histplot.c diff --git a/libvips/histograms_lut/im_histspec.c b/libvips/histogram/im_histspec.c similarity index 100% rename from libvips/histograms_lut/im_histspec.c rename to libvips/histogram/im_histspec.c diff --git a/libvips/histograms_lut/im_hsp.c b/libvips/histogram/im_hsp.c similarity index 100% rename from libvips/histograms_lut/im_hsp.c rename to libvips/histogram/im_hsp.c diff --git a/libvips/histograms_lut/im_identity.c b/libvips/histogram/im_identity.c similarity index 100% rename from libvips/histograms_lut/im_identity.c rename to libvips/histogram/im_identity.c diff --git a/libvips/histograms_lut/im_invertlut.c b/libvips/histogram/im_invertlut.c similarity index 100% rename from libvips/histograms_lut/im_invertlut.c rename to libvips/histogram/im_invertlut.c diff --git a/libvips/histograms_lut/im_lhisteq.c b/libvips/histogram/im_lhisteq.c similarity index 100% rename from libvips/histograms_lut/im_lhisteq.c rename to libvips/histogram/im_lhisteq.c diff --git a/libvips/histograms_lut/im_maplut.c b/libvips/histogram/im_maplut.c similarity index 100% rename from libvips/histograms_lut/im_maplut.c rename to libvips/histogram/im_maplut.c diff --git a/libvips/histograms_lut/im_mpercent.c b/libvips/histogram/im_mpercent.c similarity index 100% rename from libvips/histograms_lut/im_mpercent.c rename to libvips/histogram/im_mpercent.c diff --git a/libvips/histograms_lut/im_project.c b/libvips/histogram/im_project.c similarity index 100% rename from libvips/histograms_lut/im_project.c rename to libvips/histogram/im_project.c diff --git a/libvips/histograms_lut/im_stdif.c b/libvips/histogram/im_stdif.c similarity index 100% rename from libvips/histograms_lut/im_stdif.c rename to libvips/histogram/im_stdif.c diff --git a/libvips/histogram/phistogram.h b/libvips/histogram/phistogram.h new file mode 100644 index 00000000..0db69d77 --- /dev/null +++ b/libvips/histogram/phistogram.h @@ -0,0 +1,77 @@ +/* base class for all histogram operations + */ + +/* + + Copyright (C) 1991-2005 The National Gallery + + This library 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.1 of the License, or (at your option) any later version. + + This library 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 library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifndef VIPS_PHISTOGRAM_H +#define VIPS_PHISTOGRAM_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +#include + +#define VIPS_TYPE_HISTOGRAM (vips_histogram_get_type()) +#define VIPS_HISTOGRAM( obj ) \ + (G_TYPE_CHECK_INSTANCE_CAST( (obj), \ + VIPS_TYPE_HISTOGRAM, VipsHistogram )) +#define VIPS_HISTOGRAM_CLASS( klass ) \ + (G_TYPE_CHECK_CLASS_CAST( (klass), \ + VIPS_TYPE_HISTOGRAM, VipsHistogramClass)) +#define VIPS_IS_HISTOGRAM( obj ) \ + (G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_HISTOGRAM )) +#define VIPS_IS_HISTOGRAM_CLASS( klass ) \ + (G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_HISTOGRAM )) +#define VIPS_HISTOGRAM_GET_CLASS( obj ) \ + (G_TYPE_INSTANCE_GET_CLASS( (obj), \ + VIPS_TYPE_HISTOGRAM, VipsHistogramClass )) + +typedef struct _VipsHistogram { + VipsOperation parent_instance; + + /* All have an output image. + */ + VipsImage *out; + +} VipsHistogram; + +typedef struct _VipsHistogramClass { + VipsOperationClass parent_class; + +} VipsHistogramClass; + +GType vips_histogram_get_type( void ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*VIPS_PHISTOGRAM_H*/ + + diff --git a/libvips/histograms_lut/tone.c b/libvips/histogram/tone.c similarity index 100% rename from libvips/histograms_lut/tone.c rename to libvips/histogram/tone.c