新手问题:如何对pictureBox1中的每个像素进行处理?

DavidLeeeeee 2011-04-13 03:59:11
我不知道具体的语法语句,请具体一点。(BMP格式)
PS:在pictureBox2中输出处理的结果。
...全文
173 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
DavidLeeeeee 2011-04-14
  • 打赏
  • 举报
回复
比如我想做一个灰度图像的二值化,就是把它变成黑白图片怎么做?
zhoujk 2011-04-14
  • 打赏
  • 举报
回复
GetPixel 和 SetPixel 可行,但是慢得很,和VB里读图像的速度差不多,到我的资源去下载一个代码,使用 MemoryStream 的方法,直接在图像文件和多维数组之间进行转换,这个代码两个问题,第一,是用2005版写的,你现在用要测试一下,第二,使用了多维数组,所以速度肯定比较慢,但是直观
DavidLeeeeee 2011-04-14
  • 打赏
  • 举报
回复
哦,明白了,谢谢各位了!!!!!结贴啦~
DavidLeeeeee 2011-04-14
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 zhaoyycit 的回复:]

楼主 代码都有了,表达的意思也很明确 自己把代码拷贝下来试试就知道了
[/Quote]
你的是很明确但是你的控件和我的不一样,而且读取图片的方式也不一样。
zhaoyycit 2011-04-14
  • 打赏
  • 举报
回复
楼主 代码都有了,表达的意思也很明确 自己把代码拷贝下来试试就知道了
BlackPointofSun 2011-04-13
  • 打赏
  • 举报
回复
GetPixel,SetPixel。就这两个方法了
zhaoyycit 2011-04-13
  • 打赏
  • 举报
回复
代码上面已经贴过,楼主请过目。。。。
我姓区不姓区 2011-04-13
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 a8221379 的回复:]

引用 2 楼 ojlovecd 的回复:

C# code

Image img = pictureBox1.Image;
for (int i = 0; i < img.Width; i++)
{
for (int j = 0; j < img.Height; j++)
{
……
但是我不知道像素怎么表示。。。谢谢您了!!!
[/Quote]
你要做什么处理啊?说清楚你的需求
zhaoyycit 2011-04-13
  • 打赏
  • 举报
回复
可以参考MSDN
代码如下:

image1 = new Bitmap(@"C:\Documents and Settings\All Users\"
+ @"Documents\My Music\music.bmp", true);

int x, y;

// Loop through the images pixels to reset color.
for(x=0; x<image1.Width; x++)
{
for(y=0; y<image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
image1.SetPixel(x, y, newColor);
}
}

// Set the PictureBox to display the image.
PictureBox1.Image = image1;

// Display the pixel format in Label1.
Label1.Text = "Pixel format: "+image1.PixelFormat.ToString();

DavidLeeeeee 2011-04-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ojlovecd 的回复:]

C# code

Image img = pictureBox1.Image;
for (int i = 0; i < img.Width; i++)
{
for (int j = 0; j < img.Height; j++)
{
……
[/Quote]但是我不知道像素怎么表示。。。谢谢您了!!!
xiongxyt2 2011-04-13
  • 打赏
  • 举报
回复
我姓区不姓区 2011-04-13
  • 打赏
  • 举报
回复

Image img = pictureBox1.Image;
for (int i = 0; i < img.Width; i++)
{
for (int j = 0; j < img.Height; j++)
{
//to do...
}
}

DavidLeeeeee 2011-04-13
  • 打赏
  • 举报
回复
自己顶一下!有没有人知道啊?

110,566

社区成员

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

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

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