public double getDis(myCoor p2) { double di2 = (i - p2.i) * (i - p2.i); double dj2 = (j - p2.j) * (j - p2.j); return(System.Math.Sqrt((double)(di2 + dj2))); }
//求距离 public static double getDis(myCoor p2, myCoor p1) { double di2 = (p1.i - p2.i) * (p1.i - p2.i); double dj2 = (p1.j - p2.j) * (p1.j - p2.j); return(System.Math.Sqrt((double)(di2 + dj2))); }
//返回某点的RGB数组值 public byte[] getRGB_Byte(myCoor coor) { Color c = getRGB(coor); byte[] result = new byte[3]; result[0] = c.R; result[1] = c.G; result[2] = c.B; return(result); }
//设置矩阵某点的值 public void set_rgb(Color input_color, myCoor this_coor) { if (this_coor.i < 0 || this_coor.i >= height || this_coor.j < 0 || this_coor.j >= width) { return; } img_data[(int)this_coor.i, (int)this_coor.j, 0] = input_color.R; img_data[(int)this_coor.i, (int)this_coor.j, 1] = input_color.G; img_data[(int)this_coor.i, (int)this_coor.j, 2] = input_color.B; }
public Color getRGB(myCoor coor) { if (coorInRange(coor)) { Color c = Color.FromArgb(img_data[(int)coor.i, (int)coor.j, 0], img_data[(int)coor.i, (int)coor.j, 1], img_data[(int)coor.i, (int)coor.j, 2]); return(c); } else { Color c = Color.FromArgb(0, 0, 0); return(c); } }
//判断坐标coor是否在图像范围内 public bool coorInRange(myCoor coor) { if (coor.i >= height || coor.j >= width) { return(false); } else if (coor.i < 0 || coor.j < 0) { return(false); } else { return(true); } }