void operator()( const tbb::blocked_range<int>& r) const { vector2_t du, dv; inv_xform_.multDirMatrix( vector2_t( 0.5, 0), du); inv_xform_.multDirMatrix( vector2_t( 0, 0.5), dv); for( int j = r.begin(); j < r.end(); ++j) { vector2_t p ( vector2_t( active_area_.min.x, j) * inv_xform_); vector2_t p1( vector2_t( active_area_.max.x, j) * inv_xform_); vector2_t inc( ( p1 - p) / ( active_area_.max.x - active_area_.min.x)); for( int i = active_area_.min.x; i <= active_area_.max.x; ++i) { dst_( i - dst_area_.min.x, j - dst_area_.min.y) = s_( p, du, dv); p += inc; } } }
void MultiBandBlender::blend(Mat &dst, Mat &dst_mask) { for (int i = 0; i <= num_bands_; ++i) normalizeUsingWeightMap(dst_band_weights_[i], dst_pyr_laplace_[i]); if (can_use_gpu_) restoreImageFromLaplacePyrGpu(dst_pyr_laplace_); else restoreImageFromLaplacePyr(dst_pyr_laplace_); dst_ = dst_pyr_laplace_[0]; dst_ = dst_(Range(0, dst_roi_final_.height), Range(0, dst_roi_final_.width)); dst_mask_ = dst_band_weights_[0] > WEIGHT_EPS; dst_mask_ = dst_mask_(Range(0, dst_roi_final_.height), Range(0, dst_roi_final_.width)); dst_pyr_laplace_.clear(); dst_band_weights_.clear(); Blender::blend(dst, dst_mask); }
void GaussianDerivation::processderivation(int width, int height, Mat& src, Mat& dst, deviation_type deviationType) { Mat_<Vec3b> src_ = src; Mat_<Vec3b> dst_ = dst; switch (deviationType) { case 0: xDerivation(); break; case 1: yDerivation(); break; case 2: xxDerivation(); break; case 3: yyDerivation(); break; case 4: xyDerivation(); break; default: printf("error\n"); return ; } float** deviationArr[5] = {m_xDerviation,m_yDerviation,m_xxDerviation,m_yyDerviation,m_xxDerviation}; for(int row=0; row<height; row++) { for(int col=0; col<width; col++) { double xred = 0; double xgreen = 0; double xblue = 0; for(int subrow = -win_size; subrow <= win_size; subrow++) { for(int subcol = -win_size; subcol <= win_size; subcol++) { int newRow = row + subrow; int newCol = col + subcol; //if(newRow < 0 || newRow >= height) //{ // newRow = row; //} //if(newCol < 0 || newCol >= width) //{ // newCol = col; //} if (newRow<0) { newRow *= -1; } if (newRow>=height) { newRow = (height -1) - (newRow - (height - 1)); } if (newCol<0) { newCol *= -1; } if (newCol>=width) { newCol = (width -1) - (newCol - (width - 1)); } int tr = src_(newRow,newCol)[2]; int tg = src_(newRow,newCol)[1]; int tb = src_(newRow,newCol)[0]; xred += (deviationArr[deviationType][subrow + win_size][subcol + win_size] * tr); xgreen += (deviationArr[deviationType][subrow + win_size][subcol + win_size] * tg); xblue += (deviationArr[deviationType][subrow + win_size][subcol + win_size] * tb); } } int temp1 = xred * 10 + 50; int temp2 = xgreen * 10 + 50; int temp3 = xblue * 10 + 50; dst_(row,col)[2] = temp1 < 0 ? 0 : (temp1 > 255 ? 255 : temp1); dst_(row,col)[1] = temp2 < 0 ? 0 : (temp2 > 255 ? 255 : temp2); dst_(row,col)[0] = temp3 < 0 ? 0 : (temp3 > 255 ? 255 : temp3); } } }