如何将一张彩色图片转换成黑白图片

huiwww 2006-12-07 01:00:09
如何将一张彩色图片转换成黑白图片
...全文
332 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Comer 2006-12-07
  • 打赏
  • 举报
回复
mark

学习
阿发伯 2006-12-07
  • 打赏
  • 举报
回复
或者:

procedure TForm1.Button3Click(Sender: TObject);
var
P: PByteArray;
x, y: Integer;
Gray: Integer;
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
Bmp.Assign(Image1.Picture.Bitmap);
Bmp.PixelFormat := pf24bit;
for y := 0 to Bmp.Height - 1 do
begin
P := Bmp.ScanLine[y];
for x := 0 to Bmp.Width - 1 do
begin
Gray := Round(P[3*x+2] * 0.3 + P[3*x+1] * 0.59 + P[3*x] * 0.11);
P[3*x+2] := Byte(Gray);
P[3*x+1] := Byte(Gray);
P[3*x] := Byte(Gray);
end;
end;
Canvas.Draw(0, 0, Bmp);
Bmp.Free;
end;
阿发伯 2006-12-07
  • 打赏
  • 举报
回复
或者:

procedure TForm1.Button3Click(Sender: TObject);
var
P: PByteArray;
x, y: Integer;
Gray: Integer;
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
Bmp.Assign(Image1.Picture.Bitmap);
Bmp.PixelFormat := pf24bit;
for y := 0 to Bmp.Height - 1 do
begin
P := Bmp.ScanLine[y];
for x := 0 to Bmp.Width - 1 do
begin
Gray := Max(P[3*x+2], P[3*x+1]);
Gray := Max(Gray, P[3*x]);
P[3*x+2] := Byte(Gray);
P[3*x+1] := Byte(Gray);
P[3*x] := Byte(Gray);
end;
end;
Canvas.Draw(0, 0, Bmp);
Bmp.Free;
end;
阿发伯 2006-12-07
  • 打赏
  • 举报
回复

procedure TForm1.Button3Click(Sender: TObject);
var
P: PByteArray;
x, y: Integer;
Gray: Integer;
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
Bmp.Assign(Image1.Picture.Bitmap);
Bmp.PixelFormat := pf24bit;
for y := 0 to Bmp.Height - 1 do
begin
P := Bmp.ScanLine[y];
for x := 0 to Bmp.Width - 1 do
begin
Gray := (P[3*x+2] + P[3*x+1] + P[3*x]) div 3;
P[3*x+2] := Byte(Gray);
P[3*x+1] := Byte(Gray);
P[3*x] := Byte(Gray);
end;
end;
Canvas.Draw(0, 0, Bmp);
Bmp.Free;
end;
内容概要:本文围绕“【SCUC】N-1故障集+安全约束机组组合研究(Matlab代码实现)”展开,系统探讨电力系统在N-1故障场景下的安全约束机组组合(SCUC)问题,旨在实现系统安全性与运行经济性的协同优化。研究通过构建包含机组启停、出力计划、潮流约束、备用容量及N-1安全准则的数学模型,结合混合整数线性规划等优化算法,利用Matlab平台完成仿真求解,并引入YALMIP等建模工具提升建模效率。文档提供了完整的代码实现方案与测试案例,涵盖故障集的生成与处理方法,帮助用户掌握鲁棒性和分布鲁棒优化的基本思想,适用于电力系统安全校核与调度决策支持。; 适合人群:电力系统及相关专业的研究生、从事电力调度、能源优化的科研人员及工程技术人员。; 使用场景及目标:① 掌握N-1安全准则在机组组合中的建模方法与实现流程;② 开展安全约束机组组合(SCUC)与安全约束经济调度(SCED)的仿真分析;③ 利用Matlab/YALMIP快速搭建电力系统优化模型并进行求解与验证。; 阅读建议:建议读者结合文档内容与网盘提供的完整资源(含代码与数据),动手实践建模与调试过程,重点关注约束条件的设定、故障场景的枚举与处理策略,同时参考相关文献深化对鲁棒优化与分布鲁棒方法的理解。

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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