C#中的坐标轴 [英] Coordinate axes in C#

查看:113
本文介绍了C#中的坐标轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

在使用K-means算法的模式识别中,我需要在坐标轴上显示聚类之前和之后的点

就像我们绘制数学时一样积分

a第二个问题:Aforge.Net中的Point类是否可用于此任务

任何帮助将不胜感激

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

推荐答案

这个例子描述了我如何使用C#解决问题:



使用System;

使用System.Collections。 Generic;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Windows.Forms;



名称空间WindowsFormsApplication1

{

公共部分课程表格1:表格

{

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 * /

新双[] {17,45},/ * 9 * /

新双[] {14,47},/ * 10 * /

新双[] {2,16},/ * 11 * /

新双[] {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();

位图bm =新位图(500,500);

for(int i = 0;我< 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(转换。 ToInt32(Iris [i] [0]),Convert.ToInt32(Iris [i] [1]),Color.Green);

g.DrawImageUnscaled(bm,5,5);

}

其他

{

bm.SetPixel(Convert.ToInt32(Iris [i] [0]), Convert.ToInt32(Iris [i] [1]),Color.Blue);

g.DrawImageUnscaled(bm,5,5);

}

}

}

}

}
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);
}
}
}
}
}


这篇关于C#中的坐标轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆