private void connected( int imageWidth, int imageHeight, int x, int y, byte L)//data为图像数据,L为标记序号
{ data[y * imageWidth + x] = L; if ((x < (imageWidth - 1)) && (x >= 0))
{
if (data[y * imageWidth + x + 1] == 1)
{
connected(imageWidth, imageHeight, x + 1, y, L);
}
}
if ((x < imageWidth ) && (x > 0))
{
if (data[y * imageWidth + x - 1] == 1)//
{
connected(imageWidth, imageHeight, x - 1, y, L);
}
}//*/
if ((y < (imageHeight - 1))&&(y >= 0))
{
if (data[(y + 1) * imageWidth + x] == 1)//
{
connected( imageWidth, imageHeight, x, y + 1, L);
}
}
if ((y < imageHeight ) && (y > 0))
{
if (data[(y - 1) * imageWidth + x] == 1)//
{
connected( imageWidth, imageHeight, x, y - 1, L);
}
}//*/ } //对连通域标记
private void area( int imageWidth, int imageHeight)
{
byte L = 2;
//每个连通域进行标号,标号为1,2,3,......
for (int i = 0; i < imageHeight; i++)
{
for (int j = 0; j < imageWidth; j++)
{
if (data[i * imageWidth + j] == 1)
{
connected( imageWidth, imageHeight, j, i, L);
L += 1;
}
}
}
}为什么对某些图片进行处理的时候会出错,错误为未处理的“System.StackOverflowException”类型的异常,且当前堆栈处于溢出状态,无法计算表达式的值
{ data[y * imageWidth + x] = L; if ((x < (imageWidth - 1)) && (x >= 0))
{
if (data[y * imageWidth + x + 1] == 1)
{
connected(imageWidth, imageHeight, x + 1, y, L);
}
}
if ((x < imageWidth ) && (x > 0))
{
if (data[y * imageWidth + x - 1] == 1)//
{
connected(imageWidth, imageHeight, x - 1, y, L);
}
}//*/
if ((y < (imageHeight - 1))&&(y >= 0))
{
if (data[(y + 1) * imageWidth + x] == 1)//
{
connected( imageWidth, imageHeight, x, y + 1, L);
}
}
if ((y < imageHeight ) && (y > 0))
{
if (data[(y - 1) * imageWidth + x] == 1)//
{
connected( imageWidth, imageHeight, x, y - 1, L);
}
}//*/ } //对连通域标记
private void area( int imageWidth, int imageHeight)
{
byte L = 2;
//每个连通域进行标号,标号为1,2,3,......
for (int i = 0; i < imageHeight; i++)
{
for (int j = 0; j < imageWidth; j++)
{
if (data[i * imageWidth + j] == 1)
{
connected( imageWidth, imageHeight, j, i, L);
L += 1;
}
}
}
}为什么对某些图片进行处理的时候会出错,错误为未处理的“System.StackOverflowException”类型的异常,且当前堆栈处于溢出状态,无法计算表达式的值
解决方案 »
- VS2008设计视图打不开,求高手帮助下,百度谷歌了很久试了很多方法都行不通!
- c#web编程SQLServerDAL和SQLProfileDAL两个分别有什么作用?还有它们里边都需要些什么?谢谢
- 如何在WPF中将FlowDocument输出为RTF文件
- 大家帮帮忙,看这个问题怎么解决
- 急!我的C#程序在遍历文件时窗口不动了!!!
- 要想精通C#,都需要哪些知识? 是在那些项目中用到?
- 为什么右键不行啊!
- 求助,想利用TEXTBOX的TEXTCHANGE事件把全部TEXTBOX的数字加起来,但是怎嘛不行
- C# 有操作notepad++这类代码编辑器的API吗
- 请教大虾,怎样在后台运行一段程序,具体情况请看正文
- C#关于<计算器>一个方法看不懂求解释
- 求NB 正则
如果调用过深,使用的线程堆栈超过了配额(默认为1兆),系统就会抛出StackOverflowException。