delphi 图像灰度化处理  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 图像灰度化处理


Type
pRGBTripleArray = ^TRGBTripleArray;
TRGBTripleArray = array [0 .. 65535] of TRGBTriple;
Ttemplate=record
end;

procedure TForm1.Button5Click(Sender: TObject);
var
   Gray,x,y:Integer;
   p:pRGBTripleArray;
   BM:TBitmap;
begin
  BM:=TBitmap.Create;
  BM.Assign(Image1.Picture.Graphic);
  Image1.Picture.Assign(BM);
  BM.free;

   for y:=1 to Image1.Picture.Height -1 do
   begin
   p:=Image1.Picture.Bitmap.ScanLine[Y];
   for x:=1 to Image1.Picture.Width-1 do
   begin
   //采用YUV与RGB颜色空间变换的公式,即Y=0.3R+0.59G+0.11B
   Gray:=Round(p[x].rgbtRed*0.3+p[x].rgbtGreen*0.59+p[x].rgbtBlue*0.11);
   p[x].rgbtRed :=Byte(Gray);
   p[x].rgbtGreen:=Byte(Gray);
   p[X].rgbtBlue :=Byte(Gray);
   end;
   end;
   Image1.Invalidate;

end;

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.050075054168701 seconds