WIL説明書(C++)  3.0.0

下図の2値画像を2値ブローブ解析して得られたリージョンにより処理対象画像の輝度統計を算出する処理です。

【処理対象】 【2値画像】
key_UC8_M.png
key_BIN_M.png
【リージョン】
Measure.StatisticsEx.png

処理時間:

    0.118 msec : FVCL.Blob.CFvBlob
    0.036 msec : FVCL.Blob.GetList
    0.013 msec : FVCL.Blob.GetSortList
    0.210 msec : FVCL.Measure.CFvProjection.Execute


サンプルコード:
// $Revision: 1.3 $
void Projection2()
{
#ifdef _UNICODE
typedef std::wstring _TSTRING;
#else
typedef std::string _TSTRING;
#endif
FVCL::Data::CFvImage src(_T("./key_UC8_M.png"));
FVCL::Data::CFvImage bin(_T("./key_BIN_M.png"));
double msec;
std::map<_TSTRING, double> times;
// --------------------------------------------------
// 2値ブローブ解析.
{
watch.Start();
FVCL::Blob::CFvBlob parser(&bin, &result);
FVCL::Blob::CFvBlobParam& param = parser.GetParam();
parser.Execute();
msec = watch.Stop();
times[_T("FVCL.Blob.CFvBlob")] = msec;
}
// --------------------------------------------------
// 2値ブローブ解析結果のフィルタリングとソート.
FHANDLE hresult = result.GetHandle();
FVCL::Blob::CFvBlobData data(hresult, 0);
FVCL::CFvBuffer<UINT> blob_numbers;
{
watch.Start();
filters.resize(1);
filters[0].SetType(FVCL::Blob::FeatureType::AREA);
filters[0].SetMin(100);
filters[0].SetMax(FVCL::TypeRange::INT::Upper);
FVCL::Blob::GetList(hresult, filters, &blob_numbers);
msec = watch.Stop();
times[_T("FVCL.Blob.GetList")] = msec;
}
{
watch.Start();
msec = watch.Stop();
times[_T("FVCL.Blob.GetSortList")] = msec;
}
// --------------------------------------------------
// 計測.
{
watch.Start();
{
data.SetBlobNo( blob_numbers[0] );
data.GetRegion(&region);
}
msec = watch.Stop();
times[_T("FVCL.Measure.CFvProjection.Execute")] = msec;
_tprintf(_T("%-5s,%5s,%9s,%9s,%9s,%9s,%9s,%9s\n"),
_T("No."), _T("Count"), _T("Sum"), _T("Mean"), _T("Min"), _T("Max"), _T("Sigma"), _T("Var"));
for(UINT i=0 ; i<result_x.GetCount() ; i++)
{
FVCL::Statistics& stat = result_x[i];
_tprintf(_T("[%03d] %5d,%9.0f,%9.3f,%9.3f,%9.3f,%9.3f,%9.3f\n"),
i, stat.Count, stat.Sum, stat.Mean, stat.Min, stat.Max, stat.Sigma, stat.Variance);
}
}
// --------------------------------------------------
_tprintf(_T("\n"));
for(std::map<_TSTRING, double>::iterator iter = times.begin() ; iter != times.end() ; iter++)
{
_tprintf(_T("%9.3f msec : %s\n"), iter->second, iter->first.c_str());
}
}

Documentation copyright © 2007 FAST Corporation. [B-001864]
Generated on 2023年11月02日(木) 10時12分56秒 for WIL説明書(C++) by doxygen 1.8.11