本文整理匯總了C#中System.Int32.Max方法的典型用法代碼示例。如果您正苦於以下問題:C# Int32.Max方法的具體用法?C# Int32.Max怎麽用?C# Int32.Max使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Int32
的用法示例。
在下文中一共展示了Int32.Max方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetGuidePoint
/// <summary>
/// 獲取驗證碼圖片的baseline和meanline在X軸上的坐標
/// </summary>
public static void GetGuidePoint()
{
int[] pointArray = new int[ImgBoundary.rightUpPoint.Y];
int i = 0, j = 0;
//找到每一列從字符底部到字符頂部遇到的第一個字符像素的X坐標值
for (j = ImgBoundary.leftDownPoint.Y; j < ImgBoundary.rightUpPoint.Y; j++)
{
pointArray[j] = 0;
for (i = ImgBoundary.rightUpPoint.X; i > ImgBoundary.leftDownPoint.X; i--)
{
if (0 == BinaryArray[i,j])
{
pointArray[j] = i;
break;
}
}
}
//找出上述X坐標值中數量最多的X值作為baseline
Int32[] Histogram = new Int32[ImgBoundary.rightUpPoint.Y];
Array.Clear(Histogram, 0, ImgBoundary.rightUpPoint.Y);
foreach (Int32 b in pointArray)
{
if(b != 0)
{
Histogram[b]++;
}
}
//根據研究對象的特征,高於baseline三個像素以上的區域才會被認為是在baseline以下區域,因此將得到的坐標值+3個像素點作為baseline的值
GuidePoint.X = Array.IndexOf(Histogram, Histogram.Max());// +3;
//找到每一列從字符頂部到字符底部遇到的第一個字符像素的X坐標值
for (j = ImgBoundary.leftDownPoint.Y; j < ImgBoundary.rightUpPoint.Y; j++)
{
pointArray[j] = 0;
for (i = ImgBoundary.leftDownPoint.X; i < ImgBoundary.rightUpPoint.X; i++)
{
if (0 == BinaryArray[i,j])
{
pointArray[j] = i;
break;
}
}
}
//找到上述X值中數量最多的點作為meanline的參考點
Array.Clear(Histogram, 0, ImgBoundary.rightUpPoint.X); // 初始化
foreach (Int32 b in pointArray)
{
if(b != 0)
{
Histogram[b]++; // 統計直方圖
}
}
//小於meanline 2個像素的會被認為是meanline以上的區域,故直接將meanline減2個像素
Int32 midValIndex = Array.IndexOf(Histogram, Histogram.Max());
int tmpVal = ImgBoundary.leftDownPoint.X + (ImgBoundary.rightUpPoint.X - ImgBoundary.leftDownPoint.X) / 5;
//防止meanline以上沒有有效像素,故並不直接以計算值作為guidePoint
if(midValIndex > tmpVal)
{
GuidePoint.Y = midValIndex;
}
else
{
GuidePoint.Y = tmpVal;
}
}