本文整理匯總了C#中System.Image.And方法的典型用法代碼示例。如果您正苦於以下問題:C# Image.And方法的具體用法?C# Image.And怎麽用?C# Image.And使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Image
的用法示例。
在下文中一共展示了Image.And方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: processImage
private void processImage(Image<Bgr, byte> frame, out Image<Gray, byte> probabilityMap, out Rectangle prevSearchArea, out Box2D foundBox)
{
prevSearchArea = searchArea;
//convert to HSV
var hsvImg = frame.Convert<Hsv, byte>(); //<<parallel operation>>
//back-project ratio hist => create probability map
probabilityMap = ratioHist.BackProject(hsvImg.SplitChannels(0, 1)); //or new Image<Gray, byte>[]{ hsvImg[0], hsvImg[1]...} //<<parallel operation>>
//user constraints...
Image<Gray, byte> mask = hsvImg.InRange(new Hsv(0, 0, minV), new Hsv(0, 0, maxV), Byte.MaxValue, 2);
probabilityMap.And(mask, inPlace:true);
//run Camshift algorithm to find new object position, size and angle
foundBox = Camshift.Process(probabilityMap, searchArea); //<<parallel operation>>
var foundArea = Rectangle.Round(foundBox.GetMinArea());
searchArea = foundArea.Inflate(0.05, 0.05, frame.Size); //inflate found area for search (X factor)...
if (searchArea.IsEmpty) isROISelected = false; //reset tracking
}
示例2: trackCamshift
private void trackCamshift(Image<Bgr, byte> frame, Rectangle searchArea, out Image<Gray, byte> probabilityMap, out Box2D foundBox)
{
const int PROBABILITY_MIN_VAL = (int)(0.3f * Byte.MaxValue);
//convert to HSV
var hsvImg = frame.Convert<Hsv, byte>(); //<<parallel operation>>
//back-project ratio hist => create probability map
probabilityMap = ratioHist.BackProject(hsvImg.SplitChannels(0, 1)); //or new Image<Gray, byte>[]{ hsvImg[0], hsvImg[1]...} //<<parallel operation>>
//user constraints...
Image<Gray, byte> mask = hsvImg.InRange(new Hsv(0, 0, minV), new Hsv(0, 0, maxV), Byte.MaxValue, 2);
probabilityMap.And(mask, inPlace: true);
//run Camshift algorithm to find new object position, size and angle
CentralMoments centralMoments;
foundBox = Camshift.Process(probabilityMap, searchArea, Meanshift.DEFAULT_TERM, out centralMoments); //<<parallel operation>>
//stopping conditions
float avgIntensity = centralMoments.Mu00 / (foundBox.Size.Area() + Single.Epsilon);
if (avgIntensity < PROBABILITY_MIN_VAL || foundBox.Size.IsEmpty || foundBox.GetMinArea().Area() < 5 * 5)
{
foundBox = Box2D.Empty; //invalid box
}
}