panoutils.cpp
Go to the documentation of this file.
00001 
00002 #include "pano_core/panoutils.h"
00003 
00004 namespace pano{
00005 
00006 void mdImageByFloatWeights(const cv::Mat& img, const cv::Mat& weights, cv::Mat& output,
00007                 MDoperator md, std::vector<cv::Mat>* cache_channels) {
00008 
00009         std::vector<cv::Mat> _tchannels(3);
00010         if(cache_channels == NULL)  /* cache the channels if possible to avoid re-mallocs */
00011                 cache_channels = &_tchannels;
00012         std::vector<cv::Mat>& channels = *cache_channels;
00013 
00014 
00015         if( img.type () != CV_32FC3 || weights.type () != CV_32FC1 )
00016         { /* force the input to be float. otherwise, weird artifacts can happen!
00017                calling func is responsible for scaling / saturation. */
00018                 throw "nonsense, must have float type!" ;
00019         }
00020 
00021         cv::split(img, channels);
00022         md(channels[0], weights, channels[0], 1, -1);
00023         md(channels[1], weights, channels[1], 1, -1);
00024         md(channels[2], weights, channels[2], 1, -1);
00025         cv::merge(channels,output);
00026 
00027 }
00028 
00029 
00030 void mdImageByDoubleWeights(const cv::Mat& img, const cv::Mat& weights, cv::Mat& output,
00031                 MDoperator md, std::vector<cv::Mat>* cache_channels) {
00032 
00033         std::vector<cv::Mat> _tchannels(3);
00034         if(cache_channels == NULL)  /* cache the channels if possible to avoid re-mallocs */
00035                 cache_channels = &_tchannels;
00036         std::vector<cv::Mat>& channels = *cache_channels;
00037 
00038 
00039         if( img.type () != CV_64FC3 || weights.type () != CV_64FC1 )
00040         { /* force the input to be double. otherwise, weird artifacts can happen!
00041                calling func is responsible for scaling / saturation. */
00042                 throw "nonsense, must have float type!" ;
00043         }
00044 
00045         cv::split(img, channels);
00046         md(channels[0], weights, channels[0], 1, -1);
00047         md(channels[1], weights, channels[1], 1, -1);
00048         md(channels[2], weights, channels[2], 1, -1);
00049         cv::merge(channels,output);
00050 
00051 }
00052 
00053 
00054 }//namespace pano
00055 


pano_core
Author(s): Ethan Rublee
autogenerated on Mon Oct 6 2014 08:04:38