private void button3_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { MessageBox.Show(this, "Every CLUSTER will be in a specific color", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); label8.Visible = true; //System.Threading.Thread.Sleep(20); this.Update(); ReadImage r = new ReadImage(@openFileDialog1.FileName); double[][] data = r.getData; double[][] res; bool[][] mim; CLUSTER c = new CLUSTER(data, clustersNumber, exp, eps); if (algoType == 0) { res = c.ClusterMyDataByC_Mean(); } else { res = c.clusterByGK(P); } mim = c.cluster_BY_data(); //System. pictureBox2.BackgroundImage = r.IMAGE.Bitmap; UnsafeBitmap temp = new UnsafeBitmap(r.IMAGE.Width, r.IMAGE.Height); temp.LockBitmap(); for (int x = 0; x < mim[0].Length; x++) { for (int y = 0; y < mim.Length; y++) { if (mim[y][x]) { temp.SetPixel(x % temp.Width, x / temp.Width, new PixelData(COLORS[y].R, COLORS[y].G, COLORS[y].B)); break; } } } pictureBox3.BackgroundImage = temp.Bitmap; temp.UnlockBitmap(); r.IMAGE.UnlockBitmap(); } label8.Visible = false; }
private void button1_Click(object sender, EventArgs e) { MessageBox.Show(this, "Every group of points which belongs to the same CLUSTER will be in the same color", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); double[][] data = new double[po.Count][]; double[][] res; for (int f = 0; f < data.Length; f++) { data[f] = new double[2]; data[f][0] = po[f].X; data[f][1] = po[f].Y; } CLUSTER c = new CLUSTER(data, clustersNumber, exp, eps); if (algoType == 0) { res = c.ClusterMyDataByC_Mean(); } else { res = c.clusterByGK(P); } gr.Clear(Color.WhiteSmoke); bool[][] cl = c.cluster_BY_data(); for (int p = 0; p < data.Length; p++) { for (int q = 0; q < cl.Length; q++) { if (cl[q][p]) { gr.FillEllipse(new SolidBrush(COLORS[q]), (float)data[p][0], (float)data[p][1], 4.0f, 4.0f); break; } } } button1.Enabled = false; po.Clear(); ii = 0; }
private void button2_Click(object sender, EventArgs e) { ReadImage r = new ReadImage(@"G:\HandWriting\logo_4.bmp"); double[][] data = r.getData; double[][] res; bool[][] mim; CLUSTER c = new CLUSTER(data, 6, 2, 0.0001); res = c.ClusterMyDataByC_Mean(); mim = c.cluster_BY_data(); // pictureBox1.BackgroundImage = r.IMAGE.Bitmap; UnsafeBitmap temp = new UnsafeBitmap(r.IMAGE.Width, r.IMAGE.Height); PixelData[] colors = new PixelData[6]; colors[0] = new PixelData(Color.Coral.R, Color.Coral.G, Color.Coral.B); colors[1] = new PixelData(Color.Peru.R, Color.Peru.G, Color.Peru.B); colors[2] = new PixelData(Color.Goldenrod.R, Color.Goldenrod.G, Color.Goldenrod.B); colors[3] = new PixelData(Color.DarkKhaki.R, Color.DarkKhaki.G, Color.DarkKhaki.B); colors[4] = new PixelData(Color.Yellow.R, Color.Yellow.G, Color.Yellow.B); colors[5] = new PixelData(Color.WhiteSmoke.R, Color.WhiteSmoke.G, Color.WhiteSmoke.B); temp.LockBitmap(); for (int x = 0; x < mim[0].Length; x++) { for (int y = 0; y < mim.Length; y++) { if (mim[y][x]) { temp.SetPixel(x % temp.Width, x / temp.Width, colors[y]); break; } } } // pictureBox2.BackgroundImage = temp.Bitmap; temp.UnlockBitmap(); r.IMAGE.UnlockBitmap(); }