float YARPObjectAnalysis::SpotInternals(YARPImageOf<YarpPixelBGR>& src_seg, YARPImageOf<YarpPixelMono>& in_mask, YARPImageOf<YarpPixelMono>& out_mask, YARPImageOf<YarpPixelBGR>& dest) { YARPShapeBoundary sb; sb.SetFromMask(in_mask); sb.ScaleAboutCenter(shrink); YARPImageOf<YarpPixelMono> mask_small; SatisfySize(src_seg,mask_small); sb.GetMask(mask_small); ColorMap color_map, color_map2, color_id; YARPImageOf<YarpPixelInt> cluster0, cluster1; SatisfySize(src_seg,cluster0); SatisfySize(src_seg,cluster1); int iid = 1; IMGFOR(src_seg,x,y) { NetInt32 addr = HashColor(src_seg(x,y)); ColorMap::iterator it = color_id.find(addr); if (it == color_id.end()) { color_id[addr] = iid; it = color_id.find(addr); iid++; } cluster0(x,y) = (*it).second; }
void AdaptiveManifoldFilterN::filter(InputArray src, OutputArray dst, InputArray joint) { CV_Assert(sigma_s_ >= 1 && (sigma_r_ > 0 && sigma_r_ <= 1)); num_pca_iterations_ = std::max(1, num_pca_iterations_); initBuffers(src, joint); curTreeHeight = tree_height_ <= 0 ? computeManifoldTreeHeight(sigma_s_, sigma_r_) : tree_height_; sigma_r_over_sqrt_2 = (float) (sigma_r_ / sqrt(2.0)); const double seedCoef = jointCn[0].at<float>(srcSize.height/2, srcSize.width/2); const uint64 baseCoef = numeric_limits<uint64>::max() / 0xFFFF; rnd.state = static_cast<int64>(baseCoef*seedCoef); Mat1b cluster0(srcSize, 0xFF); vector<Mat> eta0(jointCnNum); for (int i = 0; i < jointCnNum; i++) h_filter(jointCn[i], eta0[i], (float)sigma_s_); buildManifoldsAndPerformFiltering(eta0, cluster0, 1); gatherResult(src, dst); }