本文整理匯總了C#中OpenCvSharp.Mat.Rectangle方法的典型用法代碼示例。如果您正苦於以下問題:C# Mat.Rectangle方法的具體用法?C# Mat.Rectangle怎麽用?C# Mat.Rectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenCvSharp.Mat
的用法示例。
在下文中一共展示了Mat.Rectangle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Run
public void Run()
{
Mat src = Cv2.ImRead(FilePath.Image.Lenna, ImreadModes.GrayScale);
// Histogram view
const int Width = 260, Height = 200;
Mat render = new Mat(new Size(Width, Height), MatType.CV_8UC3, Scalar.All(255));
// Calculate histogram
Mat hist = new Mat();
int[] hdims = {256}; // Histogram size for each dimension
Rangef[] ranges = { new Rangef(0,256), }; // min/max
Cv2.CalcHist(
new Mat[]{src},
new int[]{0},
null,
hist,
1,
hdims,
ranges);
// Get the max value of histogram
double minVal, maxVal;
Cv2.MinMaxLoc(hist, out minVal, out maxVal);
Scalar color = Scalar.All(100);
// Scales and draws histogram
hist = hist * (maxVal != 0 ? Height / maxVal : 0.0);
for (int j = 0; j < hdims[0]; ++j)
{
int binW = (int)((double)Width / hdims[0]);
render.Rectangle(
new Point(j * binW, render.Rows),
new Point((j + 1) * binW, render.Rows - (int)(hist.Get<float>(j))),
color,
-1);
}
using (new Window("Image", WindowMode.AutoSize | WindowMode.FreeRatio, src))
using (new Window("Histogram", WindowMode.AutoSize | WindowMode.FreeRatio, render))
{
Cv2.WaitKey();
}
}