新手求教:如何获得每个象素的RGB值或者灰度值?

arsenalxat 2004-10-10 05:48:41
打开一个图像文件之后,如何获得每个象素的RGB值或者灰度值并对其进行处理?(比如二值化或者计算灰度画灰度直方图等等)如果得到的是RGB的值如何转换成灰度值。新手,所以各位高人请讲的浅显一些。多谢了。
...全文
191 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
nwpulipeng 2004-10-10
  • 打赏
  • 举报
回复
帮顶混分
syy64 2004-10-10
  • 打赏
  • 举报
回复
比较容易。
nineclock 2004-10-10
  • 打赏
  • 举报
回复
COLORREF clr=::GetPixel(m_hdc,x,y);
CString ClrText;
ClrText.Format("R值为:%d\nG值为:%d\nB值为:%d",(int)GetRValue(clr),(int)GetGValue(clr),(int)GetBValue(clr));
::MessageBox(NULL,ClrText,"输出的RGB值",MB_OK);
真糨糊 2004-10-10
  • 打赏
  • 举报
回复
CDC::GetPixel
COLORREF GetPixel( int x, int y ) const;

COLORREF GetPixel( POINT point ) const;

Return Value

For either version of the function, an RGB color value for the color of the given point. It is –1 if the coordinates do not specify a point in the clipping region.

Parameters

x

Specifies the logical x-coordinate of the point to be examined.

y

Specifies the logical y-coordinate of the point to be examined.

point

Specifies the logical x- and y-coordinates of the point to be examined.

south2000 2004-10-10
  • 打赏
  • 举报
回复
RGB -> gray
gray=(r*0.299+g*0.587+b*0.114);

得到像素的值,你先看看书吧,关于图像格式讲的很详细。最简单的差不多是bmp位图,找一本图像编程的书看看吧,很简单的。
broadoceans 2004-10-10
  • 打赏
  • 举报
回复
可以使用Gdi+,非常方便

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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