C# 使用图像c的像素数据绘制边界框#
我正在尝试使用像素数据绘制边界框。我想生成一个像附加图像中那样的边界框。我试着画一个线图,并找到每个字符的框坐标 我对实施感到困惑。有人能给我指路吗 我的代码如下C# 使用图像c的像素数据绘制边界框#,c#,c#-4.0,histogram,image-segmentation,text-segmentation,C#,C# 4.0,Histogram,Image Segmentation,Text Segmentation,我正在尝试使用像素数据绘制边界框。我想生成一个像附加图像中那样的边界框。我试着画一个线图,并找到每个字符的框坐标 我对实施感到困惑。有人能给我指路吗 我的代码如下 private void button1_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(filename); GetBitmap(bmp); bmp.Save(@"C:\Users\harinath\Desktop\New folder
private void button1_Click(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(filename);
GetBitmap(bmp);
bmp.Save(@"C:\Users\harinath\Desktop\New folder (2)\hello.jpg");
List<System.Drawing.Point> bl = new List<System.Drawing.Point>();
List<System.Drawing.Point> wt = new List<System.Drawing.Point>();
List<System.Drawing.Point> bt = new List<System.Drawing.Point>();
int whiteColor = 0;
int blackColor = 0;
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
Color color = bmp.GetPixel(x, y);
if (color.ToArgb() == Color.White.ToArgb())
{
wt.Add(new System.Drawing.Point(x, y));
bt.Add(new System.Drawing.Point(x, 0));
}
else if (color.ToArgb() == Color.Black.ToArgb())
{
bl.Add(new System.Drawing.Point(x, y));
bt.Add(new System.Drawing.Point(x, y));
}
}
}
//int count = bt.Count;
//// Point ab = new Point();
//List<int> xlist = new List<int>();
//List<int> ylist = new List<int>();
//for (int i = 0; i < count; i++)
//{
// var a=bt[i].X;
// var b =bt[i].Y;
// if (b > 0) { }
//}
var series = new Series("test");
chart1.ChartAreas[0].AxisX.Maximum = bmp.Width;
chart1.ChartAreas[0].AxisX.Minimum = 0;
chart1.ChartAreas[0].AxisY.Maximum = bmp.Height;
chart1.ChartAreas[0].AxisY.Minimum = 0;
chart1.ChartAreas[0].AxisX.Interval = 5;
chart1.ChartAreas[0].AxisY.Interval = 2;
foreach (System.Drawing.Point ls in bt)
{
series.Points.AddXY(ls.X, ls.Y);
series.ChartType = SeriesChartType.Line;
}
chart1.Series.Add(series);
chart1.SaveImage(@"C:\Users\harinath\Desktop\New folder (2)\chart1.png", ChartImageFormat.Png);
//textBox1.Text = whiteColor.ToString();
//textBox2.Text = blackColor.ToString();
bmp.Save(@"C:\Users\harinath\Desktop\New folder (2)\hello.jpg");
}
private void按钮1\u单击(对象发送者,事件参数e)
{
位图bmp=新位图(文件名);
获取位图(bmp);
bmp.Save(@“C:\Users\harinath\Desktop\New folder(2)\hello.jpg”);
List bl=新列表();
List wt=新列表();
List bt=新列表();
int-whiteColor=0;
int blackColor=0;
对于(int x=0;x0){}
//}
var系列=新系列(“测试”);
chart1.ChartAreas[0]。axix.max=bmp.Width;
chart1.ChartAreas[0]。AxisX.Minimum=0;
chart1.ChartAreas[0]。AxisY.max=bmp.Height;
chart1.ChartAreas[0]。AxisY.Minimum=0;
chart1.ChartAreas[0]。AxisX.Interval=5;
chart1.ChartAreas[0]。AxisY.Interval=2;
foreach(bt中的系统图点ls)
{
系列.Points.AddXY(ls.X,ls.Y);
series.ChartType=serieChartType.Line;
}
图1.系列。添加(系列);
chart1.SaveImage(@“C:\Users\harinath\Desktop\New folder(2)\chart1.png”,ChartImageFormat.png);
//textBox1.Text=whiteColor.ToString();
//textBox2.Text=blackColor.ToString();
bmp.Save(@“C:\Users\harinath\Desktop\New folder(2)\hello.jpg”);
}
您想使用该图表做什么?你说的直方图是什么意思??通过图像和文本分割要获得字符的边界框,最好使用GraphicsPath,请添加字符串并使用GetBounds函数。若要跟踪位图中的内容,您需要编写代码以查找并遵循边框路径。@TaW我正试图在图像上绘制边框,我想用图表来得到字符的高度和宽度,从x坐标和最高y坐标画一个矩形cordinates@TaW我读了一些文章来获得坐标的尺寸,我需要水平和垂直投影来获得矩形的尺寸