项目要用到从图像中拷贝区域,保留像素值至另一张图片并且可改变拷贝的位置。
- 彩色图处理
//读取图像
read_image (Image, 'D:/文件/20240819/JPEGImages/Camera4_12909_001_165241368.bmp')
//绘制拷贝区域
gen_region_runs (ROI_0, [793,794,795,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835], [353,349,345,367,341,339,338,338,337,337,336,336,335,335,334,334,333,333,333,333,334,334,334,334,334,334,334,334,335,335,335,335,335,337,339,341,343,344,346,348,349,351,353,355], [356,360,364,367,368,369,369,370,371,372,373,373,374,375,375,375,375,374,374,374,374,374,374,373,373,373,373,373,373,372,372,372,372,372,371,369,367,366,364,362,360,359,357,355])
//分离通道
decompose3 (Image, Image1, Image2, Image3)
reduce_domain (Image1, ROI_0, ImageReduced1)
reduce_domain (Image2, ROI_0, ImageReduced2)
reduce_domain (Image3, ROI_0, ImageReduced3)
//获取绘制区域内的所有点的坐标
get_region_points (ROI_0, Rows, Columns)
//获取所有点的灰度值
get_grayval (ImageReduced1, Rows, Columns, Grayval1)
get_grayval (ImageReduced2, Rows, Columns, Grayval2)
get_grayval (ImageReduced3, Rows, Columns, Grayval3)
//读取要被粘贴区域的图像
read_image (Imagedest, 'D:/文件/全图/好品/Camera1_421_001_134344263.bmp')
//分离通道
decompose3 (Imagedest, Image11, Image21, Image31)
//坐标位移
tx:=200
ty:=-300
//将像素点绘制到目标图像上
for Index := 0 to |Grayval1|-1 by 1
set_grayval (Image11, Rows[Index]+ty, Columns[Index]+tx, Grayval1[Index])
set_grayval (Image21, Rows[Index]+ty, Columns[Index]+tx, Grayval2[Index])
set_grayval (Image31, Rows[Index]+ty, Columns[Index]+tx, Grayval3[Index])
endfor
//合并彩色图像
compose3 (Image11, Image21, Image31, MultiChannelImage)
//保存图像
write_image (MultiChannelImage, 'bmp', 0, 'D:/文件/20240819/paste/Camera4_12909_001_165241368_2')