MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / meanShiftSegmentation

Function meanShiftSegmentation

cuda/segmentation/src/mssegmentation.cpp:58–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56using namespace cv::gpu;
57using namespace pcl::cuda::detail;
58void meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize, DjSets &comps, TermCriteria criteria)
59
60{
61 CV_Assert(TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12));
62
63 CV_Assert(src.type() == CV_8UC4);
64 const int nrows = src.rows;
65 const int ncols = src.cols;
66 const int hr = sr;
67 const int hsp = sp;
68
69 // Perform mean shift procedure and obtain region and spatial maps
70 GpuMat h_rmap, h_spmap;
71 meanShiftProc(src, h_rmap, h_spmap, sp, sr, criteria);
72 Mat rmap = (Mat)h_rmap;
73 Mat spmap = (Mat)h_spmap;
74
75 Graph<SegmLinkVal> g(nrows * ncols, 4 * (nrows - 1) * (ncols - 1)
76 + (nrows - 1) + (ncols - 1));
77
78 // Make region adjacent graph from image
79 Vec4b r1;
80 Vec4b r2[4];
81 Vec2s sp1;
82 Vec2s sp2[4];
83 int dr[4];
84 int dsp[4];
85 for (int y = 0; y < nrows - 1; ++y)
86 {
87 Vec4b* ry = rmap.ptr<Vec4b>(y);
88 Vec4b* ryp = rmap.ptr<Vec4b>(y + 1);
89 Vec2s* spy = spmap.ptr<Vec2s>(y);
90 Vec2s* spyp = spmap.ptr<Vec2s>(y + 1);
91 for (int x = 0; x < ncols - 1; ++x)
92 {
93 r1 = ry[x];
94 sp1 = spy[x];
95
96 r2[0] = ry[x + 1];
97 r2[1] = ryp[x];
98 r2[2] = ryp[x + 1];
99 r2[3] = ryp[x];
100
101 sp2[0] = spy[x + 1];
102 sp2[1] = spyp[x];
103 sp2[2] = spyp[x + 1];
104 sp2[3] = spyp[x];
105
106 dr[0] = dist2(r1, r2[0]);
107 dr[1] = dist2(r1, r2[1]);
108 dr[2] = dist2(r1, r2[2]);
109 dsp[0] = dist2(sp1, sp2[0]);
110 dsp[1] = dist2(sp1, sp2[1]);
111 dsp[2] = dist2(sp1, sp2[2]);
112
113 r1 = ry[x + 1];
114 sp1 = spy[x + 1];
115

Callers 2

cloud_cbMethod · 0.85
cloud_cbMethod · 0.85

Calls 15

dist2Function · 0.85
pixFunction · 0.85
SegmLinkValClass · 0.85
SegmLinkClass · 0.85
sortFunction · 0.85
reserveMethod · 0.80
DeviceInfoClass · 0.50
typeMethod · 0.45
addEdgeMethod · 0.45
initMethod · 0.45
findMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected