00001 /*---------------------------------------------------------------------* 00002 | Library QgarLib, graphics analysis and recognition | 00003 | Copyright (C) 2005 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 license. | 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 /** 00029 * @file ThresBinaryImage.C 00030 * @brief Implementation of class qgar::ThresBinaryImage. 00031 * 00032 * See file ThresBinaryImage.H for the interface. 00033 * 00034 * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a> 00035 * @date July 4, 2005 09:23 00036 * @since Qgar 2.2 00037 */ 00038 00039 00040 // For RCS/CVS use: Do not delete 00041 /* $Id: ThresBinaryImage.C,v 1.1 2005/10/14 17:05:48 masini Exp $ */ 00042 00043 00044 00045 // QGAR 00046 #include <qgarlib/GenImage.H> 00047 #include <qgarlib/ThresBinaryImage.H> 00048 00049 00050 00051 namespace qgar 00052 { 00053 00054 // --------------------------------------------------------------------- 00055 // C O N S T R U C T O R S 00056 // --------------------------------------------------------------------- 00057 00058 00059 // CONSTRUCTOR 00060 00061 ThresBinaryImage::ThresBinaryImage(const GreyLevelImage& anImg, int aThres) 00062 00063 : BinaryImage(anImg.width(),anImg.height()) 00064 00065 { 00066 // Pointer to the pixel map of the given image 00067 GreyLevelImage::pointer pMapSource = anImg.pPixMap(); 00068 00069 // Pointer to the pixel map of the binarized image 00070 BinaryImage::pointer pMapRes = pPixMap(); 00071 00072 int size = _width * _height; 00073 00074 for (int iCnt = 0; iCnt < size ; ++iCnt, ++pMapRes, ++pMapSource) 00075 { 00076 *pMapRes = (*pMapSource < aThres) ? QGE_BW_BLACK : QGE_BW_WHITE; 00077 } 00078 } 00079 00080 00081 // --------------------------------------------------------------------- 00082 // V I R T U A L D E S T R U C T O R 00083 // --------------------------------------------------------------------- 00084 00085 00086 ThresBinaryImage::~ThresBinaryImage() 00087 { 00088 // VOID 00089 } 00090 00091 // --------------------------------------------------------------------- 00092 // G L O B A L F U N C T I O N S 00093 // --------------------------------------------------------------------- 00094 00095 00096 ThresBinaryImage 00097 qgThresBinarization(const GreyLevelImage& anImg, int aThres) 00098 { 00099 return ThresBinaryImage(anImg, aThres); 00100 } 00101 00102 00103 // ---------------------------------------------------------------------- 00104 00105 00106 } // namespace qgar