本文整理汇总了C#中System.Matrix.MinMax方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.MinMax方法的具体用法?C# Matrix.MinMax怎么用?C# Matrix.MinMax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Matrix
的用法示例。
在下文中一共展示了Matrix.MinMax方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button3_Click
// double[,] gR_Magnitude_Mat;
private void button3_Click(object sender, EventArgs e)
{
int scanFilterNum=0;
int W = Train_I.Width;
int H = Train_I.Height;
// Real part
Image<Gray, Double> gR_R = new Image<Gray, Double>(W, H);
gR_R2 = new double[m, n, 1];
gF_R_One_back = new float[m * n];
gF_R_back = new float[m, n];
gR_R3 = new double[H, W];
gR_R3_One = new double[H * W];
// Ouput
gR_R_Mat = new double[H * W, u * v];
// Ouput
gR_R_Picked = new Matrix<double>(H, W);
gR_R_Picked_Map = new Matrix<double>(H, W);
gR_R_One_Picked = new double[H * W];
gR_R_Picked_CS = new double[H, W];
// Imag part
Image<Gray, Double> gR_I = new Image<Gray, Double>(W, H);
double[, ,] gR_I2 = new double[m, n, 1];
float[] gF_I_One_back = new float[m * n];
float[,] gF_I_back = new float[m, n];
double[,] gR_I3 = new double[H, W];
double[] gR_I3_One = new double[H*W];
// Ouput
double[,] gR_I_Mat = new double[H*W, u*v];
// Ouput
Matrix<double> gR_I_Picked = new Matrix<double>(H, W);
Matrix<double> gR_I_Picked_Map = new Matrix<double>(H, W);
double[] gR_I_One_Picked = new double[H * W];
double[,] gR_I_Picked_CS = new double[H, W];
Matrix<double> t = new Matrix<double>(H, W);
/////////////// Filtered and save as gR_R_Mat / gR_I_Mat //////////////
for (scanFilterNum = 0; scanFilterNum < u * v; scanFilterNum++)
{
System.Console.WriteLine(scanFilterNum);
// Real part
gF_R_One_back = PickUpFilterFloat(gF_R_Mat.Data, scanFilterNum);
gF_R_back = OneToTwoFloat(gF_R_One_back, m, n); // OK
ConvolutionKernelF matrix_R = new ConvolutionKernelF(gF_R_back);
CvInvoke.cvFilter2D(Train_I, gR_R, matrix_R, new Point(0, 0));
gR_R2 = gR_R.Data;
gR_R3 = ArrayDownDim(gR_R2);
gR_R3_One = TwoToOneDouble(gR_R3);
// Imag part
gF_I_One_back = PickUpFilterFloat(gF_I_Mat.Data, pickFilterNum);
gF_I_back = OneToTwoFloat(gF_I_One_back, m, n);
ConvolutionKernelF matrix_I = new ConvolutionKernelF(gF_I_back);
CvInvoke.cvFilter2D(Train_I, gR_I, matrix_I, new Point(0, 0));
gR_I2 = gR_I.Data;
gR_I3 = ArrayDownDim(gR_I2);
gR_I3_One = TwoToOneDouble(gR_I3);
// Put into Mat
for (int q = 0; q < H * W; q++)
{
gR_R_Mat[q, scanFilterNum] = gR_R3_One[q];
gR_I_Mat[q, scanFilterNum] = gR_I3_One[q];
// gR_Magnitude_Mat[q, scanFilterNum] = Math.Sqrt((Math.Pow(gR_R3_One[q], 2) + Math.Pow(gR_I3_One[q], 2)));
}
}
/////////////// END Filtered and save as gR_R_Mat / gR_I_Mat //////////////
//////////////////////////////////////////////////////////////////// Test START/////////////////////////////////////////////////////////////////
double Imin; double Imax; Point IminLoc; Point ImaxLoc;
t.Data = gR_R3;
t.MinMax(out Imin, out Imax, out IminLoc, out ImaxLoc);
double kkk = ((Imax - Imin) / 255);
int W_gR_R3 = t.Width;
int H_gR_R3 = t.Height;
for (int i = 0; i < H_gR_R3; i++)
{
for (int j = 0; j < W_gR_R3; j++)
{
t.Data[i, j] = (float)(((t.Data[i, j] - (float)Imax) / kkk) + 255); // Mapping
}
}
t.Save(@"D:\Code\gF_R_back.bmp");
pictureBox7.Image = Image.FromFile(@"D:\Code\gF_R_back.bmp");
//////////////////////////////////////////////////////////////////// Test END /////////////////////////////////////////////////////////////////
/////////////////////////////// Show Real Part ////////////////////////////////
pickResultNum = 0;
gR_R_One_Picked = PickUpResultDouble(gR_R_Mat, pickResultNum); // Choose the p-th Gabor filtered Result
gR_R_Picked_CS = OneToTwoDouble(gR_R_One_Picked,H,W);
gR_R_Picked.Data = gR_R_Picked_CS;
// Show the choose filtered Result, mapping pixel value to [0,255]
double R_Rmin; double R_Rmax; Point R_RminLoc; Point R_RmaxLoc;
gR_R_Picked.MinMax(out R_Rmin, out R_Rmax, out R_RminLoc, out R_RmaxLoc);
double k = ((R_Rmax - R_Rmin) / 255);
int H_gR_R_Picked = gR_R_Picked.Rows;
int W_gR_R_Picked = gR_R_Picked.Cols;
for (int i = 0; i < H_gR_R_Picked; i++)
//.........这里部分代码省略.........
示例2: button5_Click
private void button5_Click(object sender, EventArgs e)
{
//Create a matrix
Matrix<float> matrix1 = new Matrix<float>(5, 7);
Byte element = 0;
//Set the elements
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 7; j++)
{
matrix1.Data[i, j] = element;
element++;
}
}
//Show the result
matrixBox1.Matrix = matrix1;
int W = matrix1.Cols;
int H = matrix1.Rows;
byte[] b = new byte[H];
// b = matrix1.GetCol(2);
// Matrix<float> gg = TakeRow(matrix1, 0);
//System.Console.WriteLine(gg);
// byte[,] a = new byte[H,W];
//a = matrix1.Data;
double min; double max; Point minLoc; Point maxLoc;
matrix1.MinMax(out min, out max, out minLoc, out maxLoc);
label4.Text = "Max = " + max;
label3.Text = "Min = " + min;
label6.Text = "W = " + W;
label5.Text = "H = " + H;
//label7.Text = "a[1,1] = " + a[1,1];
}
示例3: TestMinMax2
public void TestMinMax2()
{
Matrix<Single> matrix = new Matrix<Single> (10, 10);
matrix.SetValue (5);
matrix [5, 5] = 10;
matrix [3, 3] = 0;
double minVal = 5;
double maxVal = 5;
Point minLoc = new Point();
Point maxLoc = new Point();
matrix.MinMax (out minVal, out maxVal, out minLoc, out maxLoc);
EmguAssert.IsTrue(minVal == 0);
EmguAssert.IsTrue(maxVal == 10);
EmguAssert.IsTrue(minLoc.Equals(new Point(3, 3)));
EmguAssert.IsTrue(maxLoc.Equals(new Point(5, 5)));
}
示例4: TestMinMax
public void TestMinMax()
{
Matrix<float> mat = new Matrix<float>(30, 40);
mat.SetRandUniform(new MCvScalar(0), new MCvScalar(255));
double min, max;
Point minLoc, maxLoc;
mat.MinMax(out min, out max, out minLoc, out maxLoc, null);
}
示例5: NormalizeMatrix
public void NormalizeMatrix(ref Matrix<double> m)
{
double min;
double max;
System.Drawing.Point minPoint;
System.Drawing.Point maxPoint;
m.MinMax(out min, out max, out minPoint, out maxPoint);
max = Math.Abs(max);
min = Math.Abs(min);
if (min > max)
{
max = min;
}
for (int i = 0; i < m.Height; ++i)
{
for (int j = 0; j < m.Width; ++j)
{
m.Data[i, j] *= 1 / max;
}
}
}
示例6: AlignedROIs
/// <summary>
/// This method returns the 2 ROIs that are more "aligned", i.e. with the
/// lowest difference in the Y coordinate
/// It calculates the distances between all the ROIs and selects the appropriate pair
/// </summary>
/// <param name="ROIs"></param>
/// <returns></returns>
private MCvAvgComp[] AlignedROIs(MCvAvgComp[] ROIs)
{
MCvAvgComp[] alignedROIs = new MCvAvgComp[2];
int N = ROIs.Length;
Matrix<int> distancesY = new Matrix<int>(N, N);
distancesY = distancesY.Add(100000);
double minimum;
double maximum;
Point minimumLocation;
Point maximumLocation;
for (int i = 0; i < N; i++)
{
for (int j = i + 1; j < N; j++)
{
// If both rectangles do not intersect, we add their distance to the matrix
// MT: Min distance of 2 x roi.width
if (ROIs[j].rect.IntersectsWith(ROIs[i].rect) == false && Math.Abs(ROIs[j].rect.X - ROIs[i].rect.X) > ROIs[j].rect.Width*2.5)
distancesY[i, j] = Math.Abs(ROIs[j].rect.Y - ROIs[i].rect.Y);
}
}
distancesY.MinMax(out minimum, out maximum, out minimumLocation, out maximumLocation);
alignedROIs[0] = ROIs[minimumLocation.X];
alignedROIs[1] = ROIs[minimumLocation.Y];
return alignedROIs;
}
示例7: ForwardAlgorithm
private static void ForwardAlgorithm(ref List<Particle> particleListNew, Matrix<float> matRnormalized, Matrix<float> stateMat, Matrix<float> condMat, int tempModel = 5)
{
//Matrix<float> condMat = new Matrix<float>(3, 2);
//condMat[0, 0] = 0.7f;
//condMat[0, 1] = 0.3f;
//condMat[1, 0] = 0.7f;
//condMat[1, 1] = 0.3f;
//condMat[2, 0] = 0.3f;
//condMat[2, 1] = 0.7f;
//stateMat = new Matrix<float>(3, 3);
//stateMat[0, 0] = 0.8f;
//stateMat[0, 1] = 0.15f;
//stateMat[0, 2] = 0.05f;
//stateMat[1, 0] = 0.2f;
//stateMat[1, 1] = 0.5f;
//stateMat[1, 2] = 0.3f;
//stateMat[2, 0] = 0.05f;
//stateMat[2, 1] = 0.25f;
//stateMat[2, 2] = 0.7f;
int Dcount = 0;
int Acount = 0;
for (int i = 0; i < particleListNew.Count; i++)
{
if (particleListNew[i].isReady() == false)
{
particleListNew[i].pAlone.Add(0.5f);
continue;
}
particleListNew[i].pAlone.Add(matRnormalized[i, i]);
particleListNew[i].pAlone.RemoveAt(0);
//float obserPA = particleListNew[i].pAlone[particleListNew[i].pAlone.Count - tempModel - 1];
Matrix<float> obserMat0 = new Matrix<float>(3, 3);
Matrix<float> obserMat1 = new Matrix<float>(3, 3);
for (int j = 0; j < 3; j++)
{
obserMat0[j, j] = condMat[j, 0];
obserMat1[j, j] = condMat[j, 1];
}
Matrix<float> S = new Matrix<float>(3, tempModel + 1);
S[0, 0] = 0.33f;
S[1, 0] = 0.33f;
S[2, 0] = 0.33f;
for (int j = 0; j < tempModel; j++)
{
Matrix<float> inMat = new Matrix<float>(3, 1);
inMat[0, 0] = S[0, j];
inMat[1, 0] = S[1, j];
inMat[2, 0] = S[2, j];
Matrix<float> outMat = new Matrix<float>(3, 1);
float obserPA = particleListNew[i].pAlone[particleListNew[i].pAlone.Count - tempModel + j];
Matrix<float> obserMat = new Matrix<float>(3, 3);
if (obserPA > 0.5)
obserMat0.CopyTo(obserMat);
else
obserMat1.CopyTo(obserMat);
outMat = obserMat * stateMat.Transpose() * inMat;
outMat = outMat / outMat.Sum;
S[0, j + 1] = outMat[0, 0];
S[1, j + 1] = outMat[1, 0];
S[2, j + 1] = outMat[2, 0];
}
double pDEAD = S[0, tempModel];
double pDYING = S[1, tempModel];
double pALIVE = S[2, tempModel];
//for (int j = 0; j < particleListNew.Count; j++)
//{
// if (i == j)
// continue;
// pG += matRnormalized[i, j] * stateMat[1, particleListNew[i].lastState];
//}
//double pA = 1 - pG;
//swHere.WriteLine("P(A) = {0}\nP(G) = {1}\nsum = {2}\n", pA, pG, pG+pA);
Matrix<float> pOut = new Matrix<float>(3, 1);
pOut[0, 0] = (float)pDEAD;
pOut[1, 0] = (float)pDYING;
pOut[2, 0] = (float)pALIVE;
Matrix<float> pResult = new Matrix<float>(4, 1);
Point maxValP = new Point();
Point minValP = new Point();
double minVal, maxVal;
pOut.MinMax(out minVal, out maxVal, out minValP, out maxValP);
switch (maxValP.Y)
{
case 0:
particleListNew[i].lastState = particleListNew[i].state;
particleListNew[i].state = 0;
break;
//.........这里部分代码省略.........