Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * square_shrinker.cpp - Implementation of SquareShrinker 00004 * 00005 * Created: Tue Apr 22 2008 20:58:40 (GO2008, day 4) 00006 * Copyright 2005-2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <classifiers/square_shrinker.h> 00025 00026 #include <fvutils/color/colorspaces.h> 00027 #include <fvutils/base/roi.h> 00028 00029 #include <models/scanlines/scanlinemodel.h> 00030 #include <models/color/colormodel.h> 00031 00032 #include <cstddef> 00033 00034 namespace firevision { 00035 #if 0 /* just to make Emacs auto-indent happy */ 00036 } 00037 #endif 00038 00039 /** @class SquareShrinker <classifiers/square_shrinker.h> 00040 * Square shrinker. 00041 * This shrinker makes sure that a ROI is always squared. 00042 * @author Tim Niemueller 00043 */ 00044 00045 /** Constructor. */ 00046 SquareShrinker::SquareShrinker() 00047 : Shrinker() 00048 { 00049 } 00050 00051 00052 /** Shrink! 00053 * Do the actual shrinking. 00054 * @param roi ROI to shrink 00055 */ 00056 void 00057 SquareShrinker::shrink( ROI *roi ) 00058 { 00059 if ( roi->width < roi->height ) { 00060 roi->start.y += (roi->height - roi->width) / 2; 00061 roi->height = roi->width; 00062 } else if ( roi->width > roi->height) { 00063 roi->start.x += (roi->width - roi->height) / 2; 00064 roi->width = roi->height; 00065 } 00066 } 00067 00068 } // end namespace firevision