or.cpp

00001 
00002 /***************************************************************************
00003  *  or.cpp - Implementation for "or'ing" images together
00004  *
00005  *  Created: Fri May 13 14:57:10 2005
00006  *  Copyright  2005-2007  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 "filters/or.h"
00025 
00026 #include <core/exception.h>
00027 
00028 #include <cstddef>
00029 #include <ippi.h>
00030 
00031 namespace firevision {
00032 #if 0 /* just to make Emacs auto-indent happy */
00033 }
00034 #endif
00035 
00036 /** @class FilterOr <filters/or.h>
00037  * Or filter.
00038  * @author Tim Niemueller
00039  */
00040 
00041 /** Constructor. */
00042 FilterOr::FilterOr()
00043   : Filter("FilterOr", 2)
00044 {
00045 }
00046 
00047 
00048 void
00049 FilterOr::apply()
00050 {
00051   IppiSize size;
00052   size.width = src_roi[0]->width;
00053   size.height = src_roi[0]->height;
00054 
00055   IppStatus status;
00056 
00057   if ( (dst == NULL) || (dst == src[1]) ) {
00058     // In-place
00059     status = ippiOr_8u_C1IR(src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step),
00060                             src_roi[0]->line_step,
00061                             src[1] + (src_roi[1]->start.y * src_roi[1]->line_step) + (src_roi[1]->start.x * src_roi[1]->pixel_step),
00062                             src_roi[1]->line_step,
00063                             size);
00064     
00065   } else {
00066     status = ippiOr_8u_C1R(src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step),
00067                            src_roi[0]->line_step,
00068                            src[1] + (src_roi[1]->start.y * src_roi[1]->line_step) + (src_roi[1]->start.x * src_roi[1]->pixel_step),
00069                            src_roi[1]->line_step,
00070                            dst + (dst_roi->start.y * dst_roi->line_step) + (dst_roi->start.x * dst_roi->pixel_step),
00071                            dst_roi->line_step,
00072                            size);
00073   }
00074 
00075   if ( status != ippStsNoErr ) {
00076     throw fawkes::Exception("Or filter failed with %i\n", status);
00077   }
00078 
00079 }
00080 
00081 } // end namespace firevision