Halcom 发表于 2017-8-5 18:30:11

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

产生一副图像,修改指定行、指定列的灰度值:
dev_set_draw('margin')
dev_update_off()
read_image (Image, '43.bmp')
count_channels(Image, Channels)
if(Channels>1)
    rgb1_to_gray(Image, Image)
endif
get_image_size(Image, Width, Height)

ObjWidth:=16
ObjHeight:=14
gen_image_const(Obj, 'byte', ObjWidth, ObjHeight)
gen_image_proto(Obj, Obj, 255)

tuple_gen_sequence(0, ObjWidth-1, 1, WidthCol)
tuple_gen_const(ObjWidth, 0, WidthRow)
tuple_gen_const(ObjWidth, 200, WidthValue)
* 0-2行
set_grayval(Obj, WidthRow, WidthCol, WidthValue)
set_grayval(Obj, WidthRow+1, WidthCol, WidthValue)
set_grayval(Obj, WidthRow+2, WidthCol, WidthValue)
* ObjHeight-3-ObjHeight-1
set_grayval(Obj, WidthRow+ObjHeight-3, WidthCol, WidthValue)
set_grayval(Obj, WidthRow+ObjHeight-2, WidthCol, WidthValue)
set_grayval(Obj, WidthRow+ObjHeight-1, WidthCol, WidthValue)

tuple_gen_sequence(0, ObjHeight-1, 1, HeightRow)
tuple_gen_const(ObjHeight, 0, HeightCol)
tuple_gen_const(ObjHeight, 200, HeightValue)
* 0-1列
set_grayval(Obj, HeightRow, HeightCol, HeightValue)
set_grayval(Obj, HeightRow, HeightCol+1, HeightValue)
* ObjWidth-2-ObjWidth-1
set_grayval(Obj, HeightRow, HeightCol+ObjWidth-2, HeightValue)
set_grayval(Obj, HeightRow, HeightCol+ObjWidth-1, HeightValue)


页: [1]
查看完整版本: 产生一副图像,修改指定行、指定列的灰度值