File: test_unwrapping.cpp

package info (click to toggle)
opencv 4.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 282,092 kB
  • sloc: cpp: 1,178,079; xml: 682,621; python: 49,092; lisp: 31,150; java: 25,469; ansic: 11,039; javascript: 6,085; sh: 1,214; cs: 601; perl: 494; objc: 210; makefile: 173
file content (66 lines) | stat: -rw-r--r-- 1,720 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"

namespace opencv_test { namespace {

class CV_Unwrapping : public cvtest::BaseTest
{
public:
    CV_Unwrapping();
    ~CV_Unwrapping();
protected:
    void run(int);
};

CV_Unwrapping::CV_Unwrapping(){}

CV_Unwrapping::~CV_Unwrapping(){}

void CV_Unwrapping::run( int )
{
    int rows = 600;
    int cols = 800;
    int max = 50;

    Mat ramp(rows, cols, CV_32FC1);
    Mat wrappedRamp(rows, cols, CV_32FC1);
    Mat unwrappedRamp;
    Mat rowValues(1, cols, CV_32FC1);
    Mat wrappedRowValues(1, cols, CV_32FC1);

    for( int i = 0; i < cols; ++i )
    {
        float v = (float)i*(float)max/(float)cols;
        rowValues.at<float>(0, i) = v;
        wrappedRowValues.at<float>(0, i) = atan2(sin(v), cos(v));
    }
    for( int i = 0; i < rows; ++i )
    {
        rowValues.row(0).copyTo(ramp.row(i));
        wrappedRowValues.row(0).copyTo(wrappedRamp.row(i));
    }

    phase_unwrapping::HistogramPhaseUnwrapping::Params params;
    params.width = cols;
    params.height = rows;
    Ptr<phase_unwrapping::HistogramPhaseUnwrapping> phaseUnwrapping = phase_unwrapping::HistogramPhaseUnwrapping::create(params);
    phaseUnwrapping->unwrapPhaseMap(wrappedRamp, unwrappedRamp);

    for(int i = 0; i < rows; ++i )
    {
        for( int j = 0; j < cols; ++ j )
        {
            EXPECT_NEAR(ramp.at<float>(i, j), unwrappedRamp.at<float>(i, j), 0.001);
        }
    }
}

TEST( HistogramPhaseUnwrapping, unwrapPhaseMap )
{
    CV_Unwrapping test;
    test.safe_run();
}

}} // namespace