Thread: [Wavelet-commit] Wavelet/WImage MagickInter.hh, NONE, 1.1 ColorImage.hh, 1.7, 1.8 Image.hh, 1.18, 1
Status: Beta
Brought to you by:
herbert
From: Herbert M. D. <he...@us...> - 2008-04-17 07:27:43
|
Update of /cvsroot/wavelet/Wavelet/WImage In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv13454/WImage Modified Files: ColorImage.hh Image.hh tools.h Added Files: MagickInter.hh Log Message: Optional support for using ImageMagick's Magick++ classes for reading and writing images, also some minor additions. Index: tools.h =================================================================== RCS file: /cvsroot/wavelet/Wavelet/WImage/tools.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tools.h 13 Jul 2005 12:13:23 -0000 1.5 --- tools.h 17 Apr 2008 07:27:35 -0000 1.6 *************** *** 33,36 **** --- 33,43 ---- bool tools_equals (double d1, double d2); + /** Return true if two double values are almost equal + * @param d1 the first value + * @param d2 the second value + * @param epsilon the comparison epsilon + * @return true if almost equal */ + bool tools_epsilons (double d1, double d2, double epsilon); + /** Calculate an area from a string split to two characters * @param a1 the first character --- NEW FILE: MagickInter.hh --- /* * Interface of the image operations utilities * Author: Martin Dietze * * $Date: 2008/04/17 07:27:35 $ * $Revision: 1.1 $ * */ #ifndef MAGICK_INTER_H_INCLUDED #define MAGICK_INTER_H_INCLUDED #include <memory> #include <string> #include <WImage/ColorImage.hh> #include <Magick++/Image.h> /** * Helper functions for extended read/write support using the Magick++ classes. * This is motivated by the fact that we want to support many, many file formats * but don't want to spend our time writing import and export filters. * The implementation is quite rudimentary. All conversion is done by saving * and loading temporary files. Also, naturally (as the Wavelet lib does not * have support for this), all meta-information like e.g. transparency is lost. */ namespace MagickInter { /** * Converts a ColorImage to a Magick::Image. * @param img the ColorImage object * @param withTransparency if set to true, the returned image will contain * transparency information according to the original image's colors. * NOTE: this will only work with 3-color images using RGB color model. * @param transparentColors an array of as many members as the image has * color channels. If at a given position the original image's pixel n-tuple * has identical values, the pixel will be considered transparent. The default * value NULL stands for { -1, -1, -1 } * @param colorBytes the number of bytes per pixel (usually 1, i.e. 256 * distinct colors) * @return a corresponding Magick::Image * @exception ios_base:failure if an I/O operation did not succeed (e.g. * non-existent file, insufficient disk space etc.) * @exception invalid_argument for logical errors (e.g. unknown image file * format etc.) */ Magick::Image magickImageFromColorImageWithTransparency (ColorImage &img, bool withTransparency = false, coeff *transparentColors = NULL, int colorBytes = 1); /** * Converts a ColorImage to a Magick::Image. * @param img the ColorImage object * @return a corresponding Magick::Image * @exception ios_base:failure if an I/O operation did not succeed (e.g. * non-existent file, insufficient disk space etc.) * @exception invalid_argument for logical errors (e.g. unknown image file * format etc.) */ Magick::Image magickImageFromColorImage (ColorImage &img); /** * Converts a Magick::Image to a ColorImage. * @param img the Magick::Image object * @return an auto_ptr to the corresponding ColorImage * @exception ios_base:failure if an I/O operation did not succeed (e.g. * non-existent file, insufficient disk space etc.) * @exception invalid_argument for logical errors (e.g. unknown image file * format etc.) */ std::auto_ptr<ColorImage> colorImageFromMagickImage (Magick::Image &img); /** * Creates a ColorImage object for an image in the file system using the Magick * classes. * @param inFile the input file name * @return an auto_ptr to the new ColorImage * @exception ios_base:failure if an I/O operation did not succeed (e.g. * non-existent file, insufficient disk space etc.) * @exception invalid_argument for logical errors (e.g. unknown image file * format etc.) */ std::auto_ptr<ColorImage> obtainColorImage (const std::string &inFile); /** * Writes a ColorImage to any file format using the Magick classes. * @param img the ColorImage object * @param outFile the output file name * @param quality the quality (e.g. JPEG quality) if applicable * @exception ios_base:failure if an I/O operation did not succeed (e.g. * non-existent file, insufficient disk space etc.) * @exception invalid_argument for logical errors (e.g. unknown image file * format etc.) */ void writeColorImage (ColorImage &img, const std::string &outFile, int quality = 100); /** * Writes a ColorImage to any file format using the Magick classes. This * does not use the usual export/import approach but creates an intermediate * Magick image from the scratch. However it should be noted that the result * may differ slightly from the source image due to Magick's quantization. * @param img the ColorImage object * @param outFile the output file name * @param quality the quality (e.g. JPEG quality) if applicable * @param withTransparency if set to true, the returned image will contain * transparency information according to the original image's colors. * NOTE: this will only work with 3-color images using RGB color model. * @param transparentColors an array of as many members as the image has * color channels. If at a given position the original image's pixel n-tuple * has identical values, the pixel will be considered transparent. The default * value NULL stands for { -1, -1, -1 } * @param colorBytes the number of bytes per pixel (usually 1, i.e. 256 * distinct colors) * @exception ios_base:failure if an I/O operation did not succeed (e.g. * non-existent file, insufficient disk space etc.) * @exception invalid_argument for logical errors (e.g. unknown image file * format etc.) */ void writeColorImageWithTransparency (ColorImage &img, const std::string &outFile, int quality = 100, bool withTransparency = false, coeff *transparentColors = NULL, int colorBytes = 1); /** * Rescales and then writes a ColorImage to any file format using * the Magick classes. * @param img the ColorImage object * @param rows the target number of image rows * @param cols the target number of image cols * @param outFile the output file name * @param quality the quality (e.g. JPEG quality) if applicable * @exception ios_base:failure if an I/O operation did not succeed (e.g. * non-existent file, insufficient disk space etc.) * @exception invalid_argument for logical errors (e.g. unknown image file * format etc.) */ void scaleAndWriteColorImage (ColorImage &img, int rows, int cols, const std::string &outFile, int quality = 100); } #endif // MAGICK_INTER_H_INCLUDED Index: Image.hh =================================================================== RCS file: /cvsroot/wavelet/Wavelet/WImage/Image.hh,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Image.hh 24 Aug 2007 15:24:28 -0000 1.18 --- Image.hh 17 Apr 2008 07:27:35 -0000 1.19 *************** *** 122,125 **** --- 122,149 ---- * if both are identical: {\em true}, else {\em false} */ virtual bool epsilons (Image &img, coeff epsilon) const = 0; + /** Rough comparison. See if an image value is equal to some value according + * to a given {\em epsilon} (important for floating-point comparisons). + * @param y + * the row + * @param x + * the col + * @param value + * the value to compare to + * @param epsilon + * the epsilon + * @return + * if both are identical: {\em true}, else {\em false} */ + bool epsilonsAt (int y, int x, coeff value, coeff epsilon) const; + /** Rough comparison. See if an image value is equal to some value according + * to a given {\em epsilon} (important for floating-point comparisons). + * @param abs + * the absolute position + * @param value + * the value to compare to + * @param epsilon + * the epsilon + * @return + * if both are identical: {\em true}, else {\em false} */ + bool epsilonsAt (int abs, coeff value, coeff epsilon) const; /** Compares two images. Return {\em true} if both are equal. * @param img Index: ColorImage.hh =================================================================== RCS file: /cvsroot/wavelet/Wavelet/WImage/ColorImage.hh,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ColorImage.hh 24 Aug 2007 15:24:28 -0000 1.7 --- ColorImage.hh 17 Apr 2008 07:27:35 -0000 1.8 *************** *** 64,67 **** --- 64,74 ---- inline Image &channel (int num) { return *m_images[num]; } + /** Returns a reference to one of the color channels. + * {\em Don't change the dimensions of single channels unless you know + * what you're doing!} + * @param num the number of the color channel + * @return the color channel as a reference to an Image object */ + inline const Image &channel (int num) const { return *m_images[num]; } + #ifndef _WIN32_WCE /** Read the image. All steps independent of the file format will be |