Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
1.89/5 (3 votes)
Hello
In pattern recognition using K-means algorithm I need to show the points before and after clustering in Coordinate axes
just like we do in math when we draw points
a second question: is Point class in Aforge.Net useful to use for this task
any help will be appreciated
Posted
Comments
Sergey Alexandrovich Kryukov 23-Mar-15 16:50pm    
You need some point data, {x, y} (is it 2D?), it does not matter what is that. If you used AForge.NET regardless the points, you can use it, otherwise use anything else.
—SA
Mujeeba Haj Najeeb 24-Mar-15 10:58am    
I've got points declared as 2D array but I want to make a windows application not console application so I need to show the points before and after clustering as shown here
http://www.codeproject.com/Articles/439890/Text-Documents-Clustering-using-K-Means-Algorithm

1 solution

This is an example describes how I solved the problem using C#:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public double[][] Iris =
{
new double[] {2,14}, /*1*/
new double[] {24,56}, /*2*/
new double[] {23,51}, /*3*/
new double[] {2 ,10}, /*4*/
new double[] {20,52}, /*5*/
new double[] {19,51}, /*6*/
new double[] {13,45}, /*7*/
new double[] {16,47}, /*8*/
new double[] {17,45}, /*9*/
new double[] {14,47}, /*10*/
new double[] {2,16}, /*11*/
new double[] {19,50} /*12*/
};

int[] idx = new int[] { 1, 0, 2, 1, 0, 1, 0, 2, 0, 1, 1, 2 };

private void panel1_Click(object sender, EventArgs e)
{
Graphics g = panel1.CreateGraphics();
Bitmap bm = new Bitmap(500,500);
for (int i = 0; i < Iris.Length; i++)
{
if (idx[i] == 0)
{
bm.SetPixel(Convert.ToInt32(Iris[i][0]), Convert.ToInt32(Iris[i][1]), Color.Red);
//bm.SetPixel((int)Iris[i][0], (int)Iris[i][1], Color.Red);
g.DrawImageUnscaled(bm, 500, 500);
}
else
if (idx[i] == 1)
{
bm.SetPixel(Convert.ToInt32(Iris[i][0]), Convert.ToInt32(Iris[i][1]), Color.Green);
g.DrawImageUnscaled(bm, 5, 5);
}
else
{
bm.SetPixel(Convert.ToInt32(Iris[i][0]), Convert.ToInt32(Iris[i][1]), Color.Blue);
g.DrawImageUnscaled(bm, 5, 5);
}
}
}
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900