Hello Mat

 找回密码
 立即注册
查看: 8940|回复: 0

产生一副图像,修改指定行、指定列的灰度值

[复制链接]

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
发表于 2017-8-5 18:30:11 | 显示全部楼层 |阅读模式
产生一副图像,修改指定行、指定列的灰度值:
  1. dev_set_draw('margin')
  2. dev_update_off()
  3. read_image (Image, '43.bmp')
  4. count_channels(Image, Channels)
  5. if(Channels>1)
  6.     rgb1_to_gray(Image, Image)
  7. endif
  8. get_image_size(Image, Width, Height)

  9. ObjWidth:=16
  10. ObjHeight:=14
  11. gen_image_const(Obj, 'byte', ObjWidth, ObjHeight)
  12. gen_image_proto(Obj, Obj, 255)

  13. tuple_gen_sequence(0, ObjWidth-1, 1, WidthCol)
  14. tuple_gen_const(ObjWidth, 0, WidthRow)
  15. tuple_gen_const(ObjWidth, 200, WidthValue)
  16. * 0-2行
  17. set_grayval(Obj, WidthRow, WidthCol, WidthValue)
  18. set_grayval(Obj, WidthRow+1, WidthCol, WidthValue)
  19. set_grayval(Obj, WidthRow+2, WidthCol, WidthValue)
  20. * ObjHeight-3-ObjHeight-1
  21. set_grayval(Obj, WidthRow+ObjHeight-3, WidthCol, WidthValue)
  22. set_grayval(Obj, WidthRow+ObjHeight-2, WidthCol, WidthValue)
  23. set_grayval(Obj, WidthRow+ObjHeight-1, WidthCol, WidthValue)

  24. tuple_gen_sequence(0, ObjHeight-1, 1, HeightRow)
  25. tuple_gen_const(ObjHeight, 0, HeightCol)
  26. tuple_gen_const(ObjHeight, 200, HeightValue)
  27. * 0-1列
  28. set_grayval(Obj, HeightRow, HeightCol, HeightValue)
  29. set_grayval(Obj, HeightRow, HeightCol+1, HeightValue)
  30. * ObjWidth-2-ObjWidth-1
  31. set_grayval(Obj, HeightRow, HeightCol+ObjWidth-2, HeightValue)
  32. set_grayval(Obj, HeightRow, HeightCol+ObjWidth-1, HeightValue)
复制代码



算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-4-25 14:50 , Processed in 0.216756 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表