Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

image.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------+
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2002  Qgar Project, LORIA                             |
00004  |                                                                     |
00005  | This library is free software; you can redistribute it and/or       |
00006  | modify it under the terms of the GNU Lesser General Public          |
00007  | License version 2.1, as published by the Free Software Foundation.  |
00008  |                                                                     |
00009  | This library is distributed in the hope that it will be useful,     |
00010  | but WITHOUT ANY WARRANTY; without even the implied warranty of      |
00011  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                |
00012  | See the GNU Lesser General Public License for more details.         |
00013  |                                                                     |
00014  | The GNU Lesser General Public License is included in the file       |
00015  | LICENSE.LGPL, in the root directory of the Qgar packaging. See      |
00016  | http://www.gnu.org/licenses/lgpl.html for the terms of the licence. |
00017  | To receive a paper copy, write to the Free Software Foundation,     |
00018  | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.       |
00019  |                                                                     |
00020  | Contact Project Qgar for any information:                           |
00021  |   LORIA - équipe Qgar                                               |
00022  |   B.P. 239, 54506 Vandoeuvre-lès-Nancy Cedex, France                |
00023  |   email: qgar-contact@loria.fr                                      |
00024  |   http://www.qgar.org/                                              |
00025  *---------------------------------------------------------------------*/
00026 
00027 
00028 #ifndef __IMAGE_H_INCLUDED__
00029 #define __IMAGE_H_INCLUDED__
00030 
00031 
00032 /**
00033  * @file   image.H
00034  * @brief  Definitions of global utilities for image processing.
00035  *
00036  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>
00037  * @date   December 07 2004  17:48
00038  * @since  Qgar 2.2
00039  */
00040 
00041 
00042 // For RCS/CVS use: Do not delete
00043 /* $Id: image.H,v 1.2 2005/09/15 18:19:35 masini Exp $ */
00044 
00045 
00046 
00047 // QGAR
00048 #include <qgarlib/QgarErrorDomain.H>
00049 #include <qgarlib/QgarErrorInvalidArg.H>
00050 
00051 
00052 
00053 namespace qgar
00054 {
00055 
00056 // -------------------------------------------------------------------
00057 // T Y P E S
00058 // -------------------------------------------------------------------
00059 
00060 
00061 /** 
00062  * @name Types related to image processing
00063  */
00064 //@{
00065 
00066 /**
00067  * @ingroup GLOB_IMG
00068  *
00069  * @brief Coordinate axes.
00070  */
00071 enum QGEaxis
00072 {
00073 QGE_AXIS_X,
00074 QGE_AXIS_Y
00075 };
00076 
00077 
00078 /**
00079  * @ingroup GLOB_IMG
00080  *
00081  * @brief Binary pixel type (black & white)
00082  */
00083 enum QGEbw
00084 {
00085 QGE_BW_WHITE,
00086 QGE_BW_BLACK
00087 };
00088 
00089 
00090 /**
00091  * @ingroup GLOB_IMG
00092  *
00093  * @brief The 8 cardinal directions.
00094  *
00095  * @warning As the origin of the coordinates system in images
00096  * is at top left corner, North and South are upside down
00097  * for more convenience:
00098 @verbatim
00099   (0,0) +---------------------------------------------> X
00100         |
00101         |                 QGE_DIRECTION_N
00102         |                        |  
00103         |     QGE_DIRECTION_NW \ | / QGE_DIRECTION_NE
00104         |                       \|/
00105         |   QGE_DIRECTION_W -----+----- QGE_DIRECTION_E
00106         |                       /|\
00107         |     QGE_DIRECTION_SW / | \ QGE_DIRECTION_SE
00108         |                        |
00109         |                 QGE_DIRECTION_S
00110       Y V
00111 @endverbatim
00112  */
00113 enum QGEdirection
00114 {
00115 QGE_DIRECTION_N,
00116 QGE_DIRECTION_NE,
00117 QGE_DIRECTION_E,
00118 QGE_DIRECTION_SE,
00119 QGE_DIRECTION_S,
00120 QGE_DIRECTION_SW,
00121 QGE_DIRECTION_W,
00122 QGE_DIRECTION_NW
00123 };
00124 
00125 
00126 /**
00127  * @ingroup GLOB_IMG
00128  *
00129  * @brief Orientations (of a line/segment).
00130  *
00131 @verbatim
00132 QGE_ORIENTATION_VER           
00133        |
00134     \  |  QGE_ORIENTATION_DIAG_POS
00135      \ | /
00136       \|/
00137  ------+------ QGE_ORIENTATION_HOR
00138       /|\
00139      / | \
00140     /  |  QGE_ORIENTATION_DIAG_NEG
00141 @endverbatim
00142  */
00143 enum QGEorientation
00144 {
00145 QGE_ORIENTATION_HOR,
00146 QGE_ORIENTATION_DIAG_POS,
00147 QGE_ORIENTATION_VER,
00148 QGE_ORIENTATION_DIAG_NEG,
00149 QGE_ORIENTATION_ALL
00150 };
00151 
00152 
00153 /**
00154  * @ingroup GLOB_IMG
00155  *
00156  * @brief Relative positions.
00157  */
00158 enum QGEposition
00159 {
00160 QGE_POSITION_TOP,
00161 QGE_POSITION_RIGHT,
00162 QGE_POSITION_BOTTOM,
00163 QGE_POSITION_LEFT
00164 };
00165 
00166 //@}
00167 
00168 
00169 // -------------------------------------------------------------------
00170 // F U N C T I O N S   F O R   B L A C K  &  W H I T E
00171 // -------------------------------------------------------------------
00172 
00173 
00174 /** 
00175  * @name Global functions for black & white.
00176  */
00177 //@{
00178 
00179 /**
00180  * @ingroup GLOB_COLOR
00181  *
00182  * @brief Conversion
00183  *   from qgar::QGEbw (black & white) to <b>integer</b>.
00184  * Return <b>1</b> for qgar::QGE_BW_BLACK,
00185  *
00186  * and <b>0</b> for qgar::QGE_BW_WHITE.
00187  *
00188  * @param aBW  black or white (qgar::QGEbw)
00189  */
00190 inline int
00191 qgBWtoInt(QGEbw aBW)
00192 {
00193   return (aBW == QGE_BW_BLACK) ? 1 : 0;
00194 }
00195 
00196 /**
00197  * @ingroup GLOB_COLOR
00198  *
00199  * @brief Dual-conversion
00200  *   from qgar::QGEbw (black & white) to <b>integer</b>.
00201  *
00202  * Return <b>0</b> for qgar::QGE_BW_BLACK,
00203  * and <b>1</b> for qgar::QGE_BW_WHITE.
00204  *
00205  * @param aBW  black or white (qgar::QGEbw)
00206  */
00207 inline int
00208 qgBWrevInt(QGEbw aBW)
00209 {
00210   return (aBW == QGE_BW_BLACK) ? 0 : 1;
00211 }
00212 
00213 /**
00214  * @ingroup GLOB_COLOR
00215  *
00216  * @brief Conversion
00217  *   from <b>integer</b> to qgar::QGEbw (black & white).
00218  *
00219  * If the given number is <b>0</b>, return qgar::QGE_BW_WHITE,
00220  * else return qgar::QGE_BW_BLACK.
00221  *
00222  * @param anInt  an integer
00223  */
00224 inline QGEbw
00225 qgIntToBW(int anInt)
00226 {
00227   return (anInt == 0) ? QGE_BW_WHITE : QGE_BW_BLACK;
00228 }
00229 
00230 /**
00231  * @ingroup GLOB_COLOR
00232  *
00233  * @brief Dual-conversion
00234  *   from <b>integer</b> to qgar::QGEbw (black & white).
00235  *
00236  * If the given number is <b>0</b>, return qgar::QGE_BW_BLACK,
00237  * else return qgar::QGE_BW_WHITE.
00238  *
00239  * @param anInt  an integer
00240  */
00241 inline QGEbw
00242 qgIntToWB(int anInt)
00243 {
00244   return (anInt == 0) ? QGE_BW_BLACK : QGE_BW_WHITE;
00245 }
00246 
00247 /**
00248  * @ingroup GLOB_COLOR
00249  *
00250  * @brief Switch between black and white.
00251  *
00252  * Return qgar::QGE_BW_WHITE for QGE_BW_BLACK,
00253  * and QGE_BW_BLACK for qgar::QGE_BW_WHITE.
00254  *
00255  * @param aBW  black or white
00256  */
00257 inline QGEbw
00258 qgBWswitch(QGEbw aBW)
00259 {
00260   return (aBW == QGE_BW_WHITE) ? QGE_BW_BLACK : QGE_BW_WHITE;
00261 }
00262 
00263 //@}
00264 
00265 
00266 // -------------------------------------------------------------------
00267 // F U N C T I O N S   F O R   D I R E C T I O N S
00268 // -------------------------------------------------------------------
00269 
00270 
00271 // ===================================================================
00272 /** 
00273  * @name Global functions for directions
00274  * @ingroup GLOB_IMG
00275  *
00276 @verbatim
00277   (0,0) +--------------------------------------------->  X
00278         |
00279         |                 QGE_DIRECTION_N
00280         |                        |  
00281         |     QGE_DIRECTION_NW \ | / QGE_DIRECTION_NE
00282         |                       \|/
00283         |   QGE_DIRECTION_W -----+----- QGE_DIRECTION_E
00284         |                       /|\
00285         |     QGE_DIRECTION_SW / | \ QGE_DIRECTION_SE
00286         |                        |
00287         |                 QGE_DIRECTION_S
00288      Y  V
00289 @endverbatim
00290  *
00291  */
00292 // ===================================================================
00293 //@{
00294 
00295 /**
00296  * @brief Return the direction corresponding to a (X,Y) translation.
00297  * @param aDx  X translation
00298  * @param aDy  Y translation
00299  *
00300  * @warning The translation must be defined according to one of the
00301  * 8 Freeman directions, precisely, that is to say, if aDx and aDy are
00302  * both different from 0, <b>|aDx|</b> must be equal to <b>|aDy|</b>.
00303  * Otherwise, the correctness of the the result is not guaranteed.
00304  *
00305  * @exception qgar::QgarErrorDomain (arguments are 0's)
00306  */
00307 qgar::QGEdirection qgDirection(int aDx, int aDy)
00308   throw(qgar::QgarErrorDomain);
00309 
00310 
00311 /**
00312  * @brief Return the opposite direction of a given direction.
00313  * @param aDir  a direction
00314  *
00315  * @exception qgar::QgarErrorInvalidArg (unknown direction)
00316  */
00317 qgar::QGEdirection qgOpposite(qgar::QGEdirection aDir)
00318   throw(qgar::QgarErrorInvalidArg);
00319 
00320 //@}
00321 
00322 // -------------------------------------------------------------------
00323 
00324 } // namespace qgar
00325 
00326 
00327 #endif /* __IMAGE_H_INCLUDED__ */