public static ZArrayDescriptor Unrup_Line(ZArrayDescriptor zTable, int X1, int Y1, int X2, int Y2) // Устранение тренда по двум точкам { if (zTable == null) { MessageBox.Show("Unrup.cs Unrup_2pi zArrayDescriptor[regImage] == NULL"); return(zTable); } int nx = zTable.width; int ny = zTable.height; ZArrayDescriptor zArray = new ZArrayDescriptor(nx, ny); double y1 = zTable.array[X1, Y1]; double y2 = zTable.array[X2, Y2]; for (int i = 0; i < nx; i++) // Строка { for (int j = 0; j < ny; j++) { zArray.array[i, j] = zTable.array[i, j] - Line(i, X1, X2, y1, y2); } } return(zArray); }
// По убыванию public static ZArrayDescriptor Unrup_LinePluss(ZArrayDescriptor zArray, int x0, double gr) // Развертка по строкам { if (zArray == null) { MessageBox.Show("Unrup.cs Unrup_Line zArray == NULL"); return(null); } int nx = zArray.width; int ny = zArray.height; ZArrayDescriptor zArray_res = new ZArrayDescriptor(nx, ny); double a; for (int j = 0; j < ny; j++) { for (int i = 0; i < nx; i++) // Строка { a = zArray.array[i, j]; if (i > x0) { if (a < gr) { a = a + 2 * Math.PI; } } zArray_res.array[i, j] = a; } } return(zArray_res); }
public static ZArrayDescriptor Unrup_2pi(ZArrayDescriptor zTable, int b) { if (zTable == null) { MessageBox.Show("Unrup.cs Unrup_2pi zArrayDescriptor[regImage] == NULL"); return(zTable); } int nx = zTable.width; int ny = zTable.height; ZArrayDescriptor zArray = new ZArrayDescriptor(nx, ny); double pi2 = 2 * Math.PI; for (int i = b; i < nx; i++) // Строка { for (int j = 0; j < ny; j++) { zArray.array[i, j] = zTable.array[i, j] + pi2; } } for (int i = 0; i < b; i++) // Строка { for (int j = 0; j < ny; j++) { zArray.array[i, j] = zTable.array[i, j]; } } return(zArray); }
private ZArrayDescriptor BW_Line(int nx, int ny, int kv) // Ч/Б полосы с заданным числом градаций { int nx1 = nx + dx * 2; ZArrayDescriptor cmpl = new ZArrayDescriptor(nx1, ny); int step = nx / kv; for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { if ((i / step) % 2 == 0) { cmpl.array[i + dx, j] = 0; } else { cmpl.array[i + dx, j] = 255; } } } cmpl = Model_Sinus.Intens(255, 0, dx, cmpl); // Белая и черная полоса по краям return(cmpl); }
public static void Point_N(ZArrayDescriptor arr, int N1_sin, int N2_sin, int scale, Graphics g) { double max = SumClass.getMax(arr); double c4 = max / 4; double c2 = max / 2; double c3 = c4 + c2; for (int i = 0; i < N2_sin; i++) { for (int j = 0; j < N1_sin; j++) { int x = i * scale; int y = j * scale; if (arr.array[i, j] == 0) { continue; } if (arr.array[i, j] < c4) { g.FillRectangle(new SolidBrush(Color.FromArgb(0, 0, 0)), x, y, 1, 1); continue; } if (arr.array[i, j] < c2) { g.FillRectangle(new SolidBrush(Color.FromArgb(0, 250, 0)), x, y, 1, 1); continue; } if (arr.array[i, j] < c3) { g.FillRectangle(new SolidBrush(Color.FromArgb(250, 150, 0)), x, y, 1, 1); continue; } } } }
// ------------------------------------------------------------------------------------------------------ // таблица размером 256 на 256 для расшифровки public static ZArrayDescriptor Tabl_Diag_Tab256(int N1_sin, int N2_sin, int d) { China(N1_sin, N2_sin); int nx = 256; int ny = 256; int M = M1 * N1; int N = M2 * N2; int MN = N1_sin * N2_sin; // MessageBox.Show(" M1 " + M1 + " N1 " + N1 + " M2 " + M2 + " N2 " + N2 + " MN = " + N1_sin * N2_sin); //MessageBox.Show(" N1_sin= " + N1_sin + " N2_sin= " + N2_sin); ZArrayDescriptor zArray = new ZArrayDescriptor(nx, ny); for (int i = 0; i < nx; i++) // Строка { for (int j = 0; j < ny; j++) { int ix = (int)((double)i * N2_sin / nx); int iy = (int)((double)j * N1_sin / ny); int b = ((M1 * N1 * iy) + (M2 * N2 * (ix))) % MN; //if (b < N1_sin) zArray.array[i, j] = b; } } return(zArray); }
// 4 синусоиды с фазовым сдвигом public static ZArrayDescriptor Sinus(double fz, double a, double n_polos, double gamma, int kr, int Nx, int Ny, double noise) { int kr1 = kr + 1; int NX = Nx * kr1; int NY = Ny * kr1; //MessageBox.Show(" nx " + NX + " a " + a + " noise " + noise); ZArrayDescriptor cmpl = new ZArrayDescriptor(NX, NY); // Результирующий фронт Random rnd = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); // Random rnd = new Random(); double kx = 2.0 * Math.PI / NX; // a = (a - min) * 2.0 * Math.PI / (max - min); -pi +pi for (int i = 0; i < NX; i += kr1) { for (int j = 0; j < NY; j++) { double fz1 = a * (Math.Sin(kx * i * n_polos - fz) + 1) / 2; //double fz1 = a * (Math.Sin(2.0 * Math.PI * i / n_polos + fz) + 1) / 2; double fa = (0.5 - rnd.NextDouble()) * a * noise; //rnd.NextDouble() 0-1 fz1 = fz1 + fa; cmpl.array[i, j] = Math.Pow(fz1, gamma); } } return(cmpl); }
private ZArrayDescriptor BW_Line_255(ZArrayDescriptor zArray, int porog) // Повышение контраста полос { int nx = zArray.width; int ny = zArray.height; ZArrayDescriptor cmpl = new ZArrayDescriptor(nx, ny); // Результирующий фронт for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { double a = zArray.array[i, j]; if (a > porog) { cmpl.array[i, j] = 255; } else { cmpl.array[i, j] = 0; } } } return(cmpl); }
private void button13_Click(object sender, EventArgs e) // Нумерация полос полос { k1 = Convert.ToInt32(textBox1.Text); k2 = Convert.ToInt32(textBox3.Text); if (Form1.zArrayDescriptor[k1 - 1] == null) { MessageBox.Show("CorrectBr Нумерация полос zArrayDescriptor 1 == NULL"); return; } int N_line = 128; double[] am = BW_Num(Form1.zArrayDescriptor[k1 - 1], N_line); // => k2 int nx = Form1.zArrayDescriptor[k1 - 1].width; int ny = Form1.zArrayDescriptor[k1 - 1].height; ZArrayDescriptor cmpl = new ZArrayDescriptor(nx, ny); // Результирующий фронт for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { cmpl.array[i, j] = am[i]; } } Form1.zArrayDescriptor[k2 - 1] = cmpl; VisualRegImage(k2 - 1); Close(); }
/// <summary> /// Гистограмм 256 значений (256х256) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { k3 = Convert.ToInt32(textBox3.Text); k4 = Convert.ToInt32(textBox4.Text); k5 = Convert.ToInt32(textBox5.Text); if (Form1.zArrayDescriptor[k3 - 1] == null) { MessageBox.Show("Corr256 zArrayDescriptor[" + (k3 - 1) + "] == NULL"); return; } if (Form1.zArrayDescriptor[k4 - 1] == null) { MessageBox.Show("Corr256 zArrayDescriptor[" + (k4 - 1) + "] == NULL"); return; } int nx = Form1.zArrayDescriptor[k3 - 1].width; // int ny = 256; ZArrayDescriptor rez = new ZArrayDescriptor(256, 256); for (int i = 0; i < nx; i++) // После нагрузки { for (int j = 0; j < ny; j++) { int intens0 = (Int32)Form1.zArrayDescriptor[k3 - 1].array[i, j]; int intens1 = (Int32)Form1.zArrayDescriptor[k4 - 1].array[i, j]; rez.array[intens1, intens0] += 1; } } Form1.zArrayDescriptor[k5 - 1] = rez; VisualRegImage(k5 - 1); // Close(); }
//------------------------------------------------------------------------------------------------------------------------ //Random rnd = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); // double fa = (0.5- rnd.NextDouble() )* Math.PI * noise; //rnd.NextDouble() 0-1 public static ZArrayDescriptor Model_FAZA(double n, double noise) { int NX = 1024; int NY = 1024; ZArrayDescriptor cmpl = new ZArrayDescriptor(NX, NY); // Результирующий фронт Random rnd = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); // Random rnd = new Random(); for (int i = 0; i < NX; i++) { for (int j = 0; j < NY; j++) { double fz1 = (i % n); fz1 = fz1 * 2 * Math.PI / (n); double fa = (0.5 - rnd.NextDouble()) * fz1 * noise; //rnd.NextDouble() 0-1 fz1 = fz1 + fa; //if (fz1 > 2 * Math.PI) fz1 = 2 * Math.PI; //fz1 - 2 * Math.PI; //if (fz1 < 0) fz1 = 0; // + 2 * Math.PI; cmpl.array[i, j] = fz1; } } return(cmpl); }
private void lineDDA(int x1, int y1, int x2, int y2, int y0, ZArrayDescriptor zArray3D) { double dx, dy, steps; dx = x2 - x1; dy = y2 - y1; if (dy < 0) { y1 = y2; dy = -dy; } if (dx > dy) { steps = Math.Abs(dx); } else { steps = Math.Abs(dy); } double Xinc = dx / (double)steps; double Yinc = dy / (double)steps; double xx = x1 + 0.5 * Math.Sign(dx), yy = y1 + 0.5 * Math.Sign(dy); for (int ii = 0; ii < steps; ii++) { xx = (int)(xx + Xinc); yy = (int)(yy + Yinc); Put1((int)xx, (int)yy, y0, zArray3D); } }
public static ZArrayDescriptor Sub_Plane(ZArrayDescriptor amp, int x1, int y1, int x2, int y2, int x3, int y3) { int w = amp.width; int h = amp.height; ZArrayDescriptor res = new ZArrayDescriptor(w, h); double ax = x2 - x1, ay = y2 - y1, az = amp.array[x2, y2] - amp.array[x1, y1]; double bx = x3 - x1, by = y3 - y1, bz = amp.array[x3, y3] - amp.array[x1, y1]; double A = ay * bz - az * by; double B = -(ax * bz - bx * az); double C = ax * by - ay * bx; double D = -(A * x1 + B * y1 + C * amp.array[x1, y1]); A = A / C; B = B / C; D = D / C; MessageBox.Show(" A " + A.ToString() + " B " + B.ToString() + " C " + C.ToString() + " D " + D.ToString()); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { res.array[i, j] = amp.array[i, j] + (A * i + B * j + D); } } return(res); }
public static void Vizual_PictureAsRaw(ZArrayDescriptor zArrayDescriptor, PictureBox pictureBox) { int width = zArrayDescriptor.width; int height = zArrayDescriptor.height; if (width == 0 || height == 0) { MessageBox.Show("Vizual_Picture: width == 0 || height == 0"); return; } Bitmap bmp2 = new Bitmap(width, height); BitmapData data2 = ImageProcessor.getBitmapData(bmp2); for (int j = 0; j < width; j++) { for (int i = 0; i < height; i++) { int c; c = Convert.ToInt32(zArrayDescriptor.array[j, i]); Color c1 = Color.FromArgb(c, c, c); ImageProcessor.setPixel(data2, j, i, c1); } } pictureBox.Image = bmp2; bmp2.UnlockBits(data2); }
public static ZArrayDescriptor Unrup_Line2pi(ZArrayDescriptor zArray) // Развертка по строкам { if (zArray == null) { MessageBox.Show("Unrup.cs Unrup_Line2pi zArray == NULL"); return(null); } int nx = zArray.width; int ny = zArray.height; ZArrayDescriptor zArray_res = new ZArrayDescriptor(nx, ny); for (int j = 0; j < ny; j++) // Строка { int n = 0; double a1 = zArray.array[0, j]; zArray_res.array[0, j] = a1; for (int i = 1; i < nx; i++) { double a2 = zArray.array[i, j]; if (Math.Abs(a2 - a1) > 2) { n = n + 1; } zArray_res.array[i, j] = 2 * Math.PI * n + a2; //zArray_res.array[i, j] = n; a1 = a2; } } return(zArray_res); }
//---------------------------------------------------------------------------------------------------------------WB public static ZArrayDescriptor WB(double fz, double n_polos) { int NX = 1024; int NY = 1024; ZArrayDescriptor cmpl = new ZArrayDescriptor(NX, NY); // Результирующий фронт double a = 255; double kx = 2.0 * Math.PI / NX; // a = (a - min) * 2.0 * Math.PI / (max - min); -pi +pi for (int i = 0; i < NX; i++) { for (int j = 0; j < NY; j++) { double fz1 = Math.Sin(kx * i * n_polos + fz); if (fz1 < 0) { a = 0; } else { a = 255; } cmpl.array[i, j] = a; } } return(cmpl); }
public static ZArrayDescriptor ATAN_4(ZArrayDescriptor[] zArray, int regComplex, double[] fz) // regComplex -> Главное окно { int w1 = zArray[regComplex * 4].width; int h1 = zArray[regComplex * 4].height; ZArrayDescriptor faza = new ZArrayDescriptor(w1, h1); int n_sdv = fz.Length; // Число фазовых сдвигов //MessageBox.Show(" fz.Length= " + n ); for (int i = 0; i < w1; i++) { for (int j = 0; j < h1; j++) { double i1 = zArray[regComplex * 4].array[i, j]; double i2 = zArray[regComplex * 4 + 1].array[i, j]; double i3 = zArray[regComplex * 4 + 2].array[i, j]; double i4 = zArray[regComplex * 4 + 3].array[i, j]; double fz1 = i4 - i2; double fz2 = i1 - i3; double fi = Math.Atan2(fz2, fz1); //double fi = Math.Atan2(fz1, fz2) - Math.PI / 2; //if (fi < -Math.PI) fi = fi + 2 * Math.PI; faza.array[i, j] = fi; } } return(faza); }
public static ZArrayDescriptor Model_FAZA_SUBN(ZArrayDescriptor z2, ZArrayDescriptor z3, double noise) { int NX = z2.width; int NY = z2.height; double n0 = -Math.PI * noise / 3; double n1 = 2 * Math.PI + Math.PI * noise / 3; ZArrayDescriptor cmpl = new ZArrayDescriptor(NX, NY); // Результирующий фронт for (int i = 0; i < NX; i++) { for (int j = 0; j < NY; j++) { double fz1 = (z2.array[i, j] - z3.array[i, j]); if (fz1 < n0) { fz1 = fz1 + 2 * Math.PI; } if (fz1 > n1) { fz1 = fz1 - n1; } cmpl.array[i, j] = fz1; } } return(cmpl); }
public static ZArrayDescriptor Model_FAZA_SUBA(ZArrayDescriptor z2, ZArrayDescriptor z3) { int NX = z2.width; int NY = z2.height; ZArrayDescriptor cmpl = new ZArrayDescriptor(NX, NY); // Результирующий фронт for (int i = 0; i < NX; i++) { for (int j = 0; j < NY; j++) { double fz1 = Math.Abs((z2.array[i, j] - z3.array[i, j])); //if (fz1 < 0) fz1 = fz1 + 180; cmpl.array[i, j] = fz1; } } double[,] a = new double[8, 8]; a = Model_VZ(8); for (int i = 0; i < 8; i++) { MessageBox.Show(" " + a[i, 0] + " " + a[i, 1] + " " + a[i, 2] + " " + a[i, 3] + " " + a[i, 4] + " " + a[i, 5] + " " + a[i, 6] + " " + a[i, 7]); } return(cmpl); }
//------------------------------------------------------------------------------------------------------------------------------ /// <summary> /// cos от разности фаз + фазовый сдвиг => 0,1,2,3,4 ..... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button8_Click(object sender, EventArgs e) { if (Form1.zArrayDescriptor[0] == null) { MessageBox.Show("PSI zArrayDescriptor[" + 0 + "] == NULL"); return; } if (Form1.zArrayDescriptor[1] == null) { MessageBox.Show("PSI zArrayDescriptor[" + 1 + "] == NULL"); return; } int nx = Form1.zArrayDescriptor[0].width; int ny = Form1.zArrayDescriptor[0].height; ZArrayDescriptor fz1 = new ZArrayDescriptor(nx, ny); ZArrayDescriptor fz2 = new ZArrayDescriptor(nx, ny); for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { fz1.array[i, j] = Form1.zArrayDescriptor[0].array[i, j]; fz2.array[i, j] = Form1.zArrayDescriptor[1].array[i, j]; } } n_sdv = Convert.ToInt32(textBox11.Text); double[] fzrad = new double[n_sdv]; fz[0] = Convert.ToDouble(textBox1.Text); fz[1] = Convert.ToDouble(textBox2.Text); fz[2] = Convert.ToDouble(textBox3.Text); fz[3] = Convert.ToDouble(textBox4.Text); fz[4] = Convert.ToDouble(textBox7.Text); fz[5] = Convert.ToDouble(textBox8.Text); fz[6] = Convert.ToDouble(textBox9.Text); fz[7] = Convert.ToDouble(textBox10.Text); for (int i = 0; i < n_sdv; i++) { fzrad[i] = Math.PI * fz[i] / 180.0; } for (int k = 0; k < n_sdv; k++) { ZArrayDescriptor rez = new ZArrayDescriptor(nx, ny); for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { rez.array[i, j] = Math.Cos(fz1.array[i, j] - fz2.array[i, j] + fzrad[k]); } } Form1.zArrayDescriptor[k] = rez; VisualRegImage(k); } }
private double [] BW_Num(ZArrayDescriptor zArray, int N_line) // Нумерация полос { int nx = zArray.width; int ny = zArray.height; double[] am1 = new double[nx]; double[] am3 = new double[nx]; for (int i = 0; i < nx; i++) { am1[i] = zArray.array[i, N_line]; } int ii = 0, i2 = 0, i1 = 0, k1 = 0; do { i1 = ii; while (am1[ii] == 0) { ii++; if (ii >= nx) { break; } } i2 = ii--; for (int i = i1; i < i2; i++) { am3[i] = k1; } k1++; ii++; i1 = ii; if (ii >= nx) { break; } while (am1[ii] != 0) { ii++; if (ii >= nx) { break; } } i2 = ii--; for (int i = i1; i < i2; i++) { am3[i] = k1; } ii++; k1++; }while (ii < nx); return(am3); }
private void GenerateWedgeOne() { int width = WEDGE_WIDTH; int imageHeight = IMAGE_HEIGHT; int imageWidth = IMAGE_WIDTH; ZArrayDescriptor arrayDescriptor = GenerateWedge(WEDGE_M1, width, imageHeight, imageWidth, WEDGE_RATIO); Form1.zArrayDescriptor[0] = arrayDescriptor; VisualRegImage(0); }
private void GenerateWedgeTwo() { int width = WEDGE_WIDTH; int imageHeight = IMAGE_HEIGHT; int imageWidth = IMAGE_WIDTH; ZArrayDescriptor arrayDescriptor = GenerateWedge(WEDGE_M2, width, imageHeight, imageWidth, 1); Form1.zArrayDescriptor[1] = arrayDescriptor; VisualRegImage(1); }
private void Put1(int x, int y, int y0, ZArrayDescriptor zArray3D) { int nx1 = zArray3D.width; int ny1 = zArray3D.width; int xi = x; int yi = nx1 - y - y0; if (xi < nx1 && yi < ny1 && xi > 0 && yi > 0) { zArray3D.array[xi, yi] = 255; } }
private ZArrayDescriptor GenerateWedge(int mValue, int width, int imageHeight, int imageWidth, double?mRatio = null) { ZArrayDescriptor arrayDescriptor = new ZArrayDescriptor(imageWidth + BLACK_SIDE_WIDTH, imageHeight); double maxIntensity = WEDGE_MAX_INTENSITY_VALUE; if (mRatio.HasValue) { maxIntensity = mRatio.Value * (WEDGE_MAX_INTENSITY_VALUE - WEDGE_MIN_INTENSITY_VALUE) + WEDGE_MIN_INTENSITY_VALUE; } Interval <double> interval1 = new Interval <double>(0, mValue - 1); Interval <double> interval2 = new Interval <double>(WEDGE_MIN_INTENSITY_VALUE, maxIntensity); RealIntervalTransform intervalTransform = new RealIntervalTransform(interval1, interval2); int[] array = new int[width]; int currentValue = 0; //Create wedge 0..m for (int j = 0; j < width; j++) { if (currentValue >= mValue - 1) { currentValue = 0; } array[j] = currentValue; currentValue++; } CorrectBr correctBr = new CorrectBr(); double[] interpolatedClin = correctBr.InterpolateClin(clin); int qq = Convert.ToInt32(maxIntensity); //Stretch wedge to image width int k = imageWidth / (array.Length) + 1; for (int x = 0; x < imageWidth - 1; x++) { int i = x / k; for (int y = 0; y < imageHeight - 1; y++) { double value = intervalTransform.TransformToFinishIntervalValue(array[i]); //double correctedValue = CorrectBr.CorrectValueByClin(value, interpolatedClin, qq); double correctedValue = value; arrayDescriptor.array[x, y] = correctedValue; } } return(arrayDescriptor); }
// Рисование таблицы чисел по двум массивам k1 и k2 с сдвигом public static void Tabl_int(ZArrayDescriptor[] zArrayPicture, PictureBox pictureBox1, int k1, int k2, int N1_sin, int N2_sin, int scale, int d, int sdvig) { China(N1_sin, N2_sin); //MessageBox.Show(" M1 " + M1 + " N1 " + N1 + " M2 " + M2 + " N2 " + N2); if (zArrayPicture[k1] == null) { MessageBox.Show("zArrayPicture[k1] == NULL Unrup.Tabl_int "); return; } if (zArrayPicture[k2] == null) { MessageBox.Show("zArrayPicture[k2] == NULL Unrup.Tabl_int "); return; } int nx = zArrayPicture[k1].width; int ny = zArrayPicture[k1].height; //ZArrayDescriptor res = new ZArrayDescriptor(N1_sin, N2_sin); double max1 = SumClass.getMax(zArrayPicture[k1]); double min1 = SumClass.getMin(zArrayPicture[k1]); double max2 = SumClass.getMax(zArrayPicture[k2]); double min2 = SumClass.getMin(zArrayPicture[k2]); // China(N1_sin, N2_sin); Graphics g = Graphics.FromHwnd(pictureBox1.Handle); g.Clear(Color.White); ZArrayDescriptor arr = new ZArrayDescriptor(N2_sin, N1_sin); int M = M1 * N1; int N = M2 * N2; int MN = N1_sin * N2_sin; for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { //double a = res.array[i, j]; int x = (int)((zArrayPicture[k1].array[i, j] - min1) * (N2_sin - 1) / (max1 - min1)); int b2 = sdv(x, sdvig, N2_sin); int y = (int)((zArrayPicture[k2].array[i, j] - min1) * (N1_sin - 1) / (max1 - min1)); int X0 = (M * b2 + N * y) % MN; //if (X0 < d ) Point(b2 * scale, y * scale, g); if (X0 < d) { arr.array[b2, y] += 1; } } } Point_N(arr, N1_sin, N2_sin, scale, g); }
private void CalcWedgeIntensityDistribution() { ZArrayDescriptor arrayDescriptor1 = Form1.zArrayDescriptor[0]; ZArrayDescriptor arrayDescriptor2 = Form1.zArrayDescriptor[1]; Interval <double> intervalInt = new Interval <double>(0, 225); Interval <double> intervalM1 = new Interval <double>(0, WEDGE_M1); Interval <double> intervalM2 = new Interval <double>(0, WEDGE_M2); RealIntervalTransform intervalTransformM1 = new RealIntervalTransform(intervalInt, intervalM1); RealIntervalTransform intervalTransformM2 = new RealIntervalTransform(intervalInt, intervalM2); int width = arrayDescriptor1.width; int startY = 0; int height = 2; List <Point2D> pointsList = new List <Point2D>(); for (int x = 0; x < width - 1; x++) { for (int y = startY; y < height - 1; y++) { double intensity1 = arrayDescriptor1.array[x, y]; double intensity2 = arrayDescriptor2.array[x, y]; intensity1 = intervalTransformM1.TransformToFinishIntervalValue(intensity1); intensity2 = intervalTransformM2.TransformToFinishIntervalValue(intensity2); int b1 = Convert.ToInt32(intensity1); int b2 = Convert.ToInt32(intensity2); pointsList.Add(new Point2D(b1, b2)); } } RangeExtensionModelForm decisionTableForm = new RangeExtensionModelForm(); IList <Point2D> decisionTablePointsList = decisionTableForm.BuildTable(WEDGE_M1, WEDGE_M2, WEDGE_WIDTH); GraphInfo idealGraphInfo = new GraphInfo("Ideal graph", System.Windows.Media.Colors.Green, decisionTablePointsList.ToArray(), true, false); GraphInfo graph = new GraphInfo("Graphic", System.Windows.Media.Colors.Red, pointsList.ToArray(), false, true); IList <GraphInfo> graphCollection = new List <GraphInfo>() { idealGraphInfo, graph }; ShowGraphic(graphCollection); }
// Определение фазы от 0 до 2pi public static ZArrayDescriptor ATAN(ZArrayDescriptor[] zArrayPicture, int regComplex, double[] fz) { // regComplex -> Главное окно int w1 = zArrayPicture[regComplex * 4].width; int h1 = zArrayPicture[regComplex * 4].height; ZArrayDescriptor faza = new ZArrayDescriptor(w1, h1); int n_sdv = fz.Length; // Число фазовых сдвигов //MessageBox.Show(" fz.Length= " + n ); double[] i_sdv = new double[n_sdv]; double[] k_sin = new double[n_sdv]; double[] k_cos = new double[n_sdv]; for (int i = 0; i < n_sdv; i++) { k_sin[i] = Math.Sin(fz[i]); k_cos[i] = Math.Cos(fz[i]); } k_sin = Vector_orto(k_sin); // Получение ортогональных векторов для синуса и косинуса k_cos = Vector_orto(k_cos); for (int i = 0; i < w1; i++) { for (int j = 0; j < h1; j++) { for (int ii = 0; ii < n_sdv; ii++) { i_sdv[ii] = zArrayPicture[regComplex * 4 + ii].array[i, j]; } //double[] v_sdv = Vector_orto(i_sdv); // ------ Формула расшифровки фазы //double fz1 = Vector_Mul(v_sdv, k_sin); // +3 * Math.PI / 2; //double fz2 = Vector_Mul(v_sdv, k_cos); //faza.array[i, j] = 2 * Math.PI - (Math.Atan2(fz1, fz2) + Math.PI); double fz1 = Vector_Mul(i_sdv, k_sin); // +3 * Math.PI / 2; double fz2 = Vector_Mul(i_sdv, k_cos); //faza.array[i, j] = Math.Atan2(fz2, fz1); //faza.array[i, j] = 2 * Math.PI - (Math.Atan2(fz1, fz2) + Math.PI); faza.array[i, j] = Math.Atan2(fz1, fz2); } } return(faza); }
public static ZArrayDescriptor Intensity2(double nu, int Nx, int Ny, int dx, double gamma) // От черного к белому { int Nx1 = Nx; Nx = Nx + dx * 2; ZArrayDescriptor cmpl = new ZArrayDescriptor(Nx, Ny); int k = (int)(Nx1 / (nu + 1)); double[] ag = new double[Nx1]; double max = double.MinValue; double min = double.MaxValue; for (int i = 0; i < Nx1; i++) { double a = Math.Pow(255 - i / k, gamma); ag[i] = a; if (a > max) { max = a; } if (a < min) { min = a; } } for (int i = 0; i < Nx1; i++) { ag[i] = (ag[i] - min) * nu / (max - min); } for (int j = 0; j < Ny; j++) { for (int i = 0; i < Nx1; i++) { cmpl.array[i + dx, j] = ag[i]; } } cmpl = Intens(0, 255, dx, cmpl); // Белая и черная полоса по краям return(cmpl); }
public static double[] Graph_y(ZArrayDescriptor zArrayPicture, int x) { if (zArrayPicture == null) { MessageBox.Show("Graph_y zArrayPicture == null"); return(null); } int h1 = zArrayPicture.height; double[] buf = new double[h1]; for (int i = 0; i < h1; i++) { buf[i] = zArrayPicture.array[x, i]; } return(buf); }