灰度图像像素颜色亮度处理.doc

  1. 1、本文档共7页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
灰度图像像素颜色亮度处理

图像的处理(一)----灰度图像像素颜色亮度处理 以前看了一些有关图像处理的书,对我起到了很大的帮助。所以,今天我就将我学过的知识整理出来,一方面可以给人学习,另一方面也可以请各位高手指点指点。 我要说的图像处理是针对程序方面的。所以,先做一个程序来放置图形。在这里,我使用了Delphi作为工具。因为,在我使用过的众多编译器当中,Delphi对图形的支持最好。还有,这里我并不是讲语法。所以,有些代码我就不详细说明。不便之处,敬请原谅。 注意:本文章的示例程序所用的东西不超过GDI的范围。 在图像处理中,速度是很重要的。因此,我们得重新处理一下TBitmap,得到TVczhBitmap。这只是因为GetPixels和SetPixels的速度太慢,换一个方法而已。 unit untBitmapProc; interface uses Graphics, SysUtils; type TVczhBitmap=class(TBitmap) private Data:PByteArray; Line:Integer; procedure SetFormat; function GetBytePointer(X,Y:Integer):PByte; procedure SetBytes(X,Y:Integer;Value:Byte); function GetBytes(X,Y:Integer):Byte; protected published constructor Create; public property Bytes[X,Y:Integer]:Byte read GetBytes write SetBytes; procedure LoadFromFile(FileName:String); procedure ToGray; end; implementation procedure TVczhBitmap.SetFormat; begin HandleType:=bmDIB; PixelFormat:=pf24bit; end; function TVczhBitmap.GetBytePointer(X,Y:Integer):PByte; begin if LineY then begin Line:=Y; Data:=ScanLine[Y]; end; Longint(result):=Longint(Data)+X; end; procedure TVczhBitmap.SetBytes(X,Y:Integer;Value:Byte); begin GetBytePointer(X,Y)^:=Value; end; function TVczhBitmap.GetBytes(X,Y:Integer):Byte; begin result:=GetBytePointer(X,Y)^; end; constructor TVczhBitmap.Create; begin inherited Create; SetFormat; Line:=-1; end; procedure TVczhBitmap.LoadFromFile(FileName:String); begin inherited LoadFromFile(FileName); SetFormat; Line:=-1; end; procedure TVczhBitmap.ToGray; var X,Y,R:Integer; B:Byte; begin for Y:=0 to Height-1 do for X:=0 to Width-1 do begin R:=0; for B:=0 to 2 do R:=R+GetBytes(X*3+B,Y); for B:=0 to 2 do SetBytes(X*3+B,Y,R div 3); end; end; end. 此后,我们需要建立几个窗体。第一个用来显示图片,第二个用来处理图片,其他的窗体都继承自第二个窗体,包含实际的处理方法。 先看第二个窗口: unit untProc; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, untBitmapProc, StdCt

文档评论(0)

haocen + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档