图像处理,图像相减问题(在线等)

hechunsheng 2010-10-15 07:36:44
运行VS2005程序,错误提示:具有索引像素格式的图像不支持 SetPixel。
部分代码如下:
private void button1_Click(object sender, EventArgs e)
{
if (curBitmapSD != null&curBitmapSB!=null)
{
Color curColorSD;
Color curColorSB;
int ret;
for (int i = 0; i < curBitmapSD.Width; i++)
{
for (int j = 0; j < curBitmapSB.Height; j++)
{
curColorSD = curBitmapSD.GetPixel(i, j);
curColorSB = curBitmapSB.GetPixel(i, j);
ret = curColorSD.R - curColorSB.R;
curBitmapSD.SetPixel(i, j, Color.FromArgb(ret, ret, ret));
}
}
Invalidate();
}
}


图像curBitmapSD和图像curBitmapSD均为8位索引颜色图像。
求助高手解答:针对这样的图像,我应该如何做两个图像相减?
...全文
588 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
SimpleColor 2010-10-15
  • 打赏
  • 举报
回复
图像curBitmapSD和图像curBitmapSD均为8位索引颜色图像。
求助高手解答:针对这样的图像,我应该如何做两个图像相减?

这个问题我也有点想知道,不知道别人都是怎样去实现的
hechunsheng 2010-10-15
  • 打赏
  • 举报
回复
如何调整啊?大侠!
wuyq11 2010-10-15
  • 打赏
  • 举报
回复
图像的原始数据不是真正象素的值,而是索引值
调整为RGB
hechunsheng 2010-10-15
  • 打赏
  • 举报
回复
貌似不行额!依然感谢!
SimpleColor 2010-10-15
  • 打赏
  • 举报
回复
图像curBitmapSD和图像curBitmapSD均为8位索引颜色图像。
求助高手解答:针对这样的图像,我应该如何做两个图像相减?

这个问题我也有点想知道,不知道别人都是怎样去实现的
SimpleColor 2010-10-15
  • 打赏
  • 举报
回复
不好意思,一句写错了

private Bitmap curBitmapNew = new Bitmap(20, 20);
改为
private Bitmap curBitmapNew = new Bitmap(curBitmapSD.Width, curBitmapSD.Height);
SimpleColor 2010-10-15
  • 打赏
  • 举报
回复
改为这样试试
//新加
private Bitmap curBitmapNew = new Bitmap(20, 20);

private void button1_Click(object sender, EventArgs e)
{
if (curBitmapSD != null & curBitmapSB != null)
{
Color curColorSD;
Color curColorSB;
int ret;
for (int i = 0; i < curBitmapSD.Width; i++)
{
for (int j = 0; j < curBitmapSB.Height; j++)
{
curColorSD = curBitmapSD.GetPixel(i, j);
curColorSB = curBitmapSB.GetPixel(i, j);
ret = curColorSD.R - curColorSB.R;
curBitmapNew.SetPixel(i, j, Color.FromArgb(ret, ret, ret));
}
}
//新加
curBitmapSD = curBitmapNew;

Invalidate();
}
}

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧