#include <iostream>
#include <fstream>
#include <stdio.h>
static const char* keys =
{
"{@inputPath | | 保存在 yaml 文件中的包裹相位图的路径 }"
"{@outputUnwrappedName | | 要保存在 yaml 文件中并作为 8 位 png 的解包相位图的路径}"
};
static void help()
{
cout << "\n本示例演示如何使用“相位解包模块”来解包相位图"
" 保存在 yaml 文件中 (参见 extra_data\\phase_unwrapping\\data\\wrappedpeaks.yml)。"
" 文件中的 mat 名称应为“phaseValue”。结果也保存在 yaml 文件中"
" 。还创建了两个图像 (wrapped.png 和 output_name.png)"
" 以用于可视化目的。"
"\n调用方式:./example_phase_unwrapping_unwrap <input_path> <output_unwrapped_name> \n"
<< endl;
}
int main(
int argc,
char **argv)
{
if( inputPath.empty() || outputUnwrappedName.empty() )
{
help();
return -1;
}
FileStorage fsOutput(outputUnwrappedName +
".yml", FileStorage::WRITE);
fsInput["phaseValues"] >> wPhaseMap;
params.width = wPhaseMap.
cols;
params.height = wPhaseMap.
rows;
phaseUnwrapping->unwrapPhaseMap(wPhaseMap, uPhaseMap);
fsOutput << "phaseValues" << uPhaseMap;
phaseUnwrapping->getInverseReliabilityMap(reliabilities);
Mat uPhaseMap8, wPhaseMap8, reliabilities8;
uPhaseMap.convertTo(uPhaseMap8,
CV_8U, 1, 128);
imshow("reliabilities", reliabilities);
imshow("wrapped phase map", wPhaseMap8);
imshow("unwrapped phase map", uPhaseMap8);
imwrite(outputUnwrappedName + ".png", uPhaseMap8);
imwrite("reliabilities.png", reliabilities8);
bool loop = true;
while( loop )
{
char key = (char)waitKey(0);
if( key == 27 )
{
loop = false;
}
}
return 0;
}
如果数组没有元素,则返回 true。
int64_t int64
XML/YAML/JSON 文件存储类,封装了写入或读取所需的所有信息...
定义 persistence.hpp:261
int rows
行数和列数,或者当矩阵具有超过 2 个维度时为 (-1, -1)
定义 mat.hpp:2165
void convertTo(OutputArray m, int rtype, double alpha=1, double beta=0) const
使用可选缩放将数组转换为另一种数据类型。
void release()
递减引用计数器并在需要时释放矩阵。
std::string String
定义 cvstd.hpp:151
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
int main(int argc, char *argv[])
定义 highgui_qt.cpp:3
phaseUnwrapping 构造函数的参数。
Definition histogramphaseunwrapping.hpp:79
要使用此示例,包裹相位图值应作为 CV_32FC1 Mat 存储在 yml 文件中,名称为“phaseValues”。数据的路径和保存解包相位图的名称必须在命令行中设置。结果以浮点精度保存在 yml 文件中,并以 8 位图像保存以用于可视化目的。
if( inputPath.empty() || outputUnwrappedName.empty() )
{
help();
return -1;
}
FileStorage fsOutput(outputUnwrappedName +
".yml", FileStorage::WRITE);
fsInput["phaseValues"] >> wPhaseMap;
params.width = wPhaseMap.
cols;
params.height = wPhaseMap.
rows;
phaseUnwrapping->unwrapPhaseMap(wPhaseMap, uPhaseMap);
fsOutput << "phaseValues" << uPhaseMap;
phaseUnwrapping->getInverseReliabilityMap(reliabilities);
Mat uPhaseMap8, wPhaseMap8, reliabilities8;
uPhaseMap.convertTo(uPhaseMap8,
CV_8U, 1, 128);
imshow("reliabilities", reliabilities);
imshow("wrapped phase map", wPhaseMap8);
imshow("unwrapped phase map", uPhaseMap8);
imwrite(outputUnwrappedName + ".png", uPhaseMap8);
imwrite("reliabilities.png", reliabilities8);