本文整理汇总了C#中CvMat.Threshold方法的典型用法代码示例。如果您正苦于以下问题:C# CvMat.Threshold方法的具体用法?C# CvMat.Threshold怎么用?C# CvMat.Threshold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvMat
的用法示例。
在下文中一共展示了CvMat.Threshold方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetForegroundAlphaFrame
private static bool GetForegroundAlphaFrame(SensorData sensorData, bool bLimitedUsers, ICollection<int> alTrackedIndexes, ref byte[] fgAlphaFrame)
{
if (sensorData == null || sensorData.bodyIndexImage == null)
return false;
CvMat cvAlphaMap = new CvMat(sensorData.depthImageHeight, sensorData.depthImageWidth, MatrixType.U8C1);
System.IntPtr rawPtrAlpha;
cvAlphaMap.GetRawData(out rawPtrAlpha);
if (sensorData.selectedBodyIndex != 255 || bLimitedUsers)
{
// copy body-index selectively
byte btSelBI = sensorData.selectedBodyIndex;
int iBodyIndexLength = sensorData.bodyIndexImage.Length;
for (int i = 0; i < iBodyIndexLength; i++)
{
byte btBufBI = sensorData.bodyIndexImage[i];
bool bUserTracked = btSelBI != 255 ? btSelBI == btBufBI :
(btBufBI != 255 ? alTrackedIndexes.Contains((int)btBufBI) : false);
if (bUserTracked)
{
cvAlphaMap.Set1D(i, btBufBI);
}
else
{
cvAlphaMap.Set1D(i, 255);
}
}
}
else
{
// copy the entire body-index buffer
Marshal.Copy(sensorData.bodyIndexImage, 0, rawPtrAlpha, sensorData.bodyIndexImage.Length);
}
// make the image b&w
cvAlphaMap.Threshold(cvAlphaMap, 254, 255, ThresholdType.BinaryInv);
// apply erode, dilate and blur
cvAlphaMap.Erode(cvAlphaMap);
cvAlphaMap.Dilate(cvAlphaMap);
cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Blur, 5, 5);
//cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Median, 7);
// get the foreground image
Marshal.Copy(rawPtrAlpha, fgAlphaFrame, 0, fgAlphaFrame.Length);
return true;
}
示例2: recognizeNationality2
/** 所属国認識2
* @param image 所属国アイコン部分カラー画像
*/
static 所属国 recognizeNationality2( CvMat image )
{
// 閾値130.0で2値化した画像を基にする
CvMat bin = new CvMat( image.Rows, image.Cols, MatrixType.U8C1);
image.CvtColor( bin, ColorConversion.BgrToGray );
bin.Threshold( bin, 130.0, 255.0, ThresholdType.Binary );
// iel: 7
// net: 23
// http://twitpic.com/azbzjh
int count = bin.GetRows( 2, bin.Rows ).CountNonZero();
if ( count > 15 )
return 所属国.ネツァワル;
if ( count > 3 )
return 所属国.エルソード;
return 所属国.不明;
}
示例3: GetForegroundAlphaFrame
private static bool GetForegroundAlphaFrame(SensorData sensorData, ref byte[] fgAlphaFrame)
{
if(sensorData == null || sensorData.bodyIndexImage == null)
return false;
CvMat cvAlphaMap = new CvMat(sensorData.depthImageHeight, sensorData.depthImageWidth, MatrixType.U8C1);
System.IntPtr rawPtrAlpha;
cvAlphaMap.GetRawData(out rawPtrAlpha);
Marshal.Copy(sensorData.bodyIndexImage, 0, rawPtrAlpha, sensorData.bodyIndexImage.Length);
cvAlphaMap.Threshold(cvAlphaMap, 254, 255, ThresholdType.BinaryInv);
cvAlphaMap.Erode(cvAlphaMap);
cvAlphaMap.Dilate(cvAlphaMap);
cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Blur, 5, 5);
//cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Median, 7);
Marshal.Copy(rawPtrAlpha, fgAlphaFrame, 0, fgAlphaFrame.Length);
return true;
}
示例4: scoreTable2Binary
// スコア表画像を2値化
static CvMat scoreTable2Binary(CvMat scoreTable)
{
CvMat bin = new CvMat( scoreTable.Rows, scoreTable.Cols, MatrixType.U8C1);
// グレイスケール化
scoreTable.CvtColor( bin, ColorConversion.BgrToGray );
// 2値化
bin.Threshold ( bin, 150.0, 255.0, ThresholdType.Binary );
// 孤立輝点除去
bin = removeNoize ( bin );
return bin;
}