private UnsafeBitmap convertoToColoredImage(EVector[][][] EImage) { UnsafeBitmap temp = new UnsafeBitmap(EImage.Length, EImage[0].Length); temp.LockBitmap(); for (int x = 0; x < temp.Width; x++) { for (int y = 0; y < temp.Height; y++) { temp.SetPixel(x, y, new PixelData((byte)EImage[x][y][0].IntValue, (byte)EImage[x][y][1].IntValue, (byte)EImage[x][y][2].IntValue)); } } link.status = "DONE !!"; link.val = 10; doDrawing(link); return(temp); }
private void button2_Click(object sender, EventArgs e) { if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox3.Text.Length > 0) { int xP, yP, psay; try { xP = int.Parse(textBox1.Text); yP = int.Parse(textBox2.Text); psay = int.Parse(textBox3.Text); } catch (Exception) { showError1(); return; } if (xP <= 0 || yP <= 0) { showError1(); return; } /////// /// here will be the code /// of the core + creating the tab and the picBox in it. /////// Nullable <bool> colred; if (radioButton1.Checked == true) { colred = null; } else if (radioButton2.Checked == true) { colred = true; } else { colred = false; } load = new UnsafeBitmap((Bitmap)g); core = new ImageOPER(load, xP, yP, psay, colred, toolStripStatusLabel1, toolStripProgressBar1, statusStrip1); if (core.ImageType == ImageOPER.GRAY) { result = core.getEnhancedImage(); } else { result = core.getEnhancedColoredImage(); } result.UnlockBitmap(); ////// TabPage myPage = new TabPage("Image Enhance Result"); tabControl1.TabPages.Add(myPage); PictureBox pic = new PictureBox(); pic.Location = new System.Drawing.Point(6, 6); pic.Name = "pictureBox1"; pic.Size = new System.Drawing.Size(623, 425); pic.TabIndex = 0; pic.TabStop = false; pic.BackgroundImageLayout = pictureBox1.BackgroundImageLayout; pic.BackgroundImage = result.Bitmap; myPage.Controls.Add(pic); tabControl1.SelectTab(myPage); } else { showError1(); return; } }
/// <summary> /// /// </summary> /// <param name="pic"></param> /// <param name="XpatM"></param> /// <param name="YpatN"></param> /// <param name="psay"></param> /// <param name="isColored"></param> public ImageOPER(UnsafeBitmap pic, int XpatM, int YpatN, double psay, bool?isColored, System.Windows.Forms.ToolStripStatusLabel statusLabel, System.Windows.Forms.ToolStripProgressBar progressBar, System.Windows.Forms.StatusStrip strip) { this.statusLabel = statusLabel; this.progressBar = progressBar; this.strip = strip; progressBar.Value = 0; //DrawingThread = new Thread(new ParameterizedThreadStart(doDrawing)); link = new Bar_Sta("Initializing", 0); //DrawingThread.Start(link); doDrawing(link); source = pic; source.LockBitmap(); if (isColored == null) { PixelData data; Random ra = new Random(); data = source.GetPixel(ra.Next(source.Width), ra.Next(source.Height)); if (data.red == data.green && data.red == data.blue) { imageType = GRAY; } else { imageType = COLORED; } } else if (isColored.Value) { imageType = COLORED; } else { imageType = GRAY; } M = XpatM; N = YpatN; this.psay = psay; //////////// W = new double[M][][][]; card = new double[M][]; for (int i = 0; i < M; i++) { W[i] = new double[N][][]; card[i] = new double[N]; for (int j = 0; j < N; j++) { W[i][j] = new double[source.Width][]; for (int x = 0; x < source.Width; x++) { W[i][j][x] = new double[source.Height]; } } } //////////// link.status = "Filling Qx and Qy"; link.val = 3; //DrawingThread = new Thread(new ParameterizedThreadStart(doDrawing)); //DrawingThread.Start(link); doDrawing(link); fillQ(); link.status = "Filling W [i,j,x,y] "; link.val = 7; //DrawingThread = new Thread(new ParameterizedThreadStart(doDrawing)); //DrawingThread.Start(link); doDrawing(link); fillW(); if (imageType == GRAY) { imageType = GRAY; ////// link.status = "Moving to E space"; link.val = 12; doDrawing(link); ////// transformTo_Espace(); ////// link.status = "Calculating the MEANS"; link.val = 8; doDrawing(link); ////// calculate_Means(); ////// link.status = "Calculating the VARIANCES"; link.val = 13; doDrawing(link); ////// calculate_Variances(); ////// link.status = "Calculating the LAMBDAs and TAWs"; link.val = 17; doDrawing(link); ////// calculate_Lambdas_Taws(); ////// link.status = "Computing the Enhanced Image"; link.val = 10; doDrawing(link); ////// } else { imageType = COLORED; link.status = "Moving to E space"; link.val = 12; doDrawing(link); transformTo_E_Colored_Space(); link.status = "Calculating the MEANS"; link.val = 8; doDrawing(link); calculate_Colored_Means(); link.status = "Calculating the VARIANCES"; link.val = 13; doDrawing(link); calculate_Colored_Variances(); link.status = "Calculating the LAMBDAs and TAWs"; link.val = 17; doDrawing(link); calculate_Lambdas_Taws(); link.status = "Computing the Enhanced Image"; link.val = 10; doDrawing(link); /* UnsafeBitmap temp; * temp = new UnsafeBitmap(source.Width, source.Height); * temp.LockBitmap(); * transformTo_EspaceR(); * calculate_Means(); * calculate_Variances(); * calculate_Lambdas_Taws(); * temp = getEnhancedColoredImageR(temp,0); * //// * transformTo_EspaceG(); * calculate_Means(); * calculate_Variances(); * calculate_Lambdas_Taws(); * temp = getEnhancedColoredImageR(temp, 1); * //// * transformTo_EspaceB(); * calculate_Means(); * calculate_Variances(); * calculate_Lambdas_Taws(); * temp = getEnhancedColoredImageR(temp, 2);*/ } }