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); }
/// <summary> /// Синусоиды с учетом клина /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ModelSinByClinButton_Click(object sender, EventArgs e) { double[] fzrad = new double[8]; gamma = Convert.ToDouble(textBox5.Text); N_pol = Convert.ToDouble(textBox6.Text); // Число точек на полоссу N_urovn = Convert.ToDouble(textBox8.Text); // Амплитуда kr = Convert.ToInt32(textBox9.Text); // Разрядка нулями Nx = Convert.ToInt32(textBox10.Text); Ny = Convert.ToInt32(textBox12.Text); noise = Convert.ToDouble(textBox11.Text); N_sdv = Convert.ToInt32(textBox17.Text); // Число сдвигов double minIntensity = 0; if (N_sdv > 8) { MessageBox.Show("Число сдвигов больше 8", "Message", MessageBoxButtons.OK); } fzrad = new double[8]; fzrad[0] = Math.PI * Convert.ToDouble(textBox1.Text) / 180.0; // Фаза в радианах fzrad[1] = Math.PI * Convert.ToDouble(textBox2.Text) / 180.0; fzrad[2] = Math.PI * Convert.ToDouble(textBox3.Text) / 180.0; fzrad[3] = Math.PI * Convert.ToDouble(textBox4.Text) / 180.0; fzrad[4] = Math.PI * Convert.ToDouble(textBox13.Text) / 180.0; fzrad[5] = Math.PI * Convert.ToDouble(textBox14.Text) / 180.0; fzrad[6] = Math.PI * Convert.ToDouble(textBox15.Text) / 180.0; fzrad[7] = Math.PI * Convert.ToDouble(textBox16.Text) / 180.0; CorrectBr correctBr = new CorrectBr(); double[] interpolatedClin = correctBr.InterpolateClin(clin); //OnModelSin1(fzrad, N_sdv, N_urovn, gamma, N_pol, kr, Nx, Ny, noise, interpolatedClin); for (int i = 0; i < N_sdv; i++) { Form1.zArrayDescriptor[Form1.regComplex * 4 + i] = Model_Sinus.Sinus1(fzrad[i], N_urovn, N_pol, gamma, kr, Nx, Ny, noise, minIntensity, interpolatedClin); VisualRegImage(Form1.regComplex * 4 + i); } Close(); }