OpenCV
openCV Iterator를 이용한 다차원 배열의 픽셀접근 예제
hellobird
2019. 2. 3. 14:38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <opencv2/opencv.hpp> #include <3vmw9.hpp> using namespace cv; using namespace rv2; using namespace std; int main(int argc, char** argv) { int sz[3] = { 4, 4 ,4 }; Mat m(3, sz, CV_32FC3); randu(m, -1.0f, 1.0f); float max = 0.0f; MatConstIterator_<Vec3f> it = m.begin<Vec3f>(); float len2; while (it != m.end<Vec3f>()) { len2 = (*it)[0] * (*it)[0] + (*it)[1] * (*it)[1] + (*it)[2] * (*it)[2]; if (len2 > max) max = len2; ++it; } co_f(len2); return 0; } | cs |