///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Mouse Events ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void mainImage_MouseUp(object sender, MouseButtonEventArgs e) { if (currentCursorMode == CursorMode.defaultMode) { if (needPointsCapture == false) { return; } if (firstClick == null) { int x = (int) e.GetPosition(mainImage).X; int y = (int) e.GetPosition(mainImage).Y; int z = (int) zArrayDescriptor.array[x][y]; firstClick = new Point3D(x, y, z); return; } else { int x = (int) e.GetPosition(mainImage).X; int y = (int) e.GetPosition(mainImage).Y; int z = (int) zArrayDescriptor.array[x][y]; secondClick = new Point3D(x, y, z); } ZArrayDescriptor result = Pi_Class1.Z_sub(firstClick.x, firstClick.y, secondClick.x, secondClick.y, zArrayDescriptor, cosinusValue); zArrayDescriptor = result; mainImage.Source = Utils.getImageFromArray(zArrayDescriptor); adjustSliders(); needPointsCapture = false; } else if (currentCursorMode == CursorMode.graphBuildMode) { int x = (int)e.GetPosition(mainImage).X; int y = (int)e.GetPosition(mainImage).Y; Graphic graphic = new Graphic(zArrayDescriptor, x, y); // График новый graphic.Show(); } else if (currentCursorMode == CursorMode.tableBuildMode) { if (imageContainersList[8].getzArrayDescriptor() == null) { MessageBox.Show("9 изображение пустое!"); return; } if (imageContainersList[9].getzArrayDescriptor() == null) { MessageBox.Show("10 изображение пустое!"); return; } if (imageContainersList[10].getzArrayDescriptor() == null) { MessageBox.Show("11 изображение пустое!"); return; } ZArrayDescriptor[] imagesForTable = new ZArrayDescriptor[3]; imagesForTable[0] = imageContainersList[8].getzArrayDescriptor(); imagesForTable[1] = imageContainersList[9].getzArrayDescriptor(); imagesForTable[2] = imageContainersList[10].getzArrayDescriptor(); TableGenerateForm tableGenerateForm = new TableGenerateForm(imagesForTable); tableGenerateForm.setX((int)e.GetPosition(mainImage).X); tableGenerateForm.setY((int)e.GetPosition(mainImage).Y); tableGenerateForm.Show(); } else if (currentCursorMode == CursorMode.doubleGraph) { if (imageContainersList[0].getzArrayDescriptor() == null) { MessageBox.Show("1-e изображение пустое!"); return; } int x = (int)e.GetPosition(mainImage).X; int y = (int)e.GetPosition(mainImage).Y; Graphic graphic = new Graphic(zArrayDescriptor, imageContainersList[0].getzArrayDescriptor(), x, y); graphic.Show(); } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Заполнение массива гистограмм ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static void bmp_gstgr(int[,] bmp_r) { int n = n1 + n2 + 3; Int64[] buf = new Int64[n]; int[] buf1 = new int[n]; for (int i = 0; i < n1; i++) { for (int j = 0; j < n2; j++) { buf[j + (n1 - i)] += bmp_r[j, i]; } } for (int i = 0; i < n; i++) buf1[i] = glbl_faze[i]; Graphic graphic = new Graphic(n, 0, buf, buf1); graphic.Show(); }
// Расшифровка // -------------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------------- public static Bitmap pi2_rshfr(Image[] img, int sN1, int sN2, int Diag, bool rd, bool SUB_rd, int pr_obr, int sdvg_x) { China(sN1, sN2); // Вычисление формулы sN1, sN2 -> в глобальные n1, n2 int[,] bmp_r = new int[sN2 + 3, sN1 + 3]; // Массив точек в таблице 2pi int count = bmp_2pi(img, bmp_r, Diag, pr_obr, sdvg_x); // Заполнение массива bmp_r int w = img[0].Width; int h = img[0].Height; Bitmap bmp1 = new Bitmap(img[1], w, h); // 1 фаза Bitmap bmp2 = new Bitmap(img[0], w, h); // 2 фаза Bitmap bmp3 = new Bitmap(img[2], w, h); // Маска Bitmap bmp = new Bitmap( w, h); // Результат Z = new Int64[w, h]; GLBL_FAZE(n1, n2, Diag); // Заполнение массива glbl_faze[] (Все -1 кроме номеров полос) // для расшифровки glbl_faze1[] расширяется значениям номеров полос на допустимый диапазон rash_2pi(bmp1, bmp2, bmp3, bmp_r, pr_obr, sdvg_x, sN1, sN2, Diag, Z); // РАСШИФРОВКА (Заполнение Z[,]) int x1 = 24, x2 = 460, y1 = 50; //GraphClass1.grfk(w, h, x, y, Z); Int64[] sub_line = new Int64[w]; if (SUB_rd) { Z_sub(x1, x2, y1, Z, w, h, sub_line); } // //Z_sub1(x1, x2, y1, Z, w, h, bmp3, rd); // Вычитание плоскости //GraphClass1.grfk(w, x, y, Z); int x = 1075, y = 600; Int64[] buf = new Int64[w]; for (int i = 0; i < w; i++) { buf[i] = Z[i, y]; } Graphic graphic = new Graphic(w, x, buf); graphic.Show(); // График по x Int64[] buf1 = new Int64[h]; for (int i = 0; i < h; i++) { buf1[i] = Z[x, i]; } Graphic graphic1 = new Graphic(h, y, buf1); graphic1.Show(); // График по y Z_bmp(bmp, bmp3, Z); // Z -> bmp с масштабированием (bmp3 - маска) return bmp; }