图像修复: 祛除视频图像中的文字水印
By
admin
at 2019-04-23 • 0人收藏 • 1379人看过
功能:
加载视频图像之后, 手工选择需要处理的区域, 然后右键确认即可.
import win.ui; /*DSG{{*/ mainForm = win.form(text="aardio + Halcon 祛除水印(钢网), 来自 Aardio.com.cn";right=867;bottom=573) mainForm.add( button={cls="button";text="绘制祛除区域,左键拖动绘制, 右键确认 , 注意: 按一次只能绘制一次";left=13;top=20;right=200;bottom=148;z=2}; picturebox={cls="picturebox";left=207;top=0;right=868;bottom=574;z=1} ) /*}}*/ //import console //console.open() //import HOperatorSetX; import com; try{ HOperatorSetX = com.CreateObject("{6ebd90e2-d219-11d2-ade5-0000c00f4ef9}") } catch(e){ com.activeX.regsvr32("\res\halconx.dll"); HOperatorSetX = com.CreateObject("{6ebd90e2-d219-11d2-ade5-0000c00f4ef9}") } Image = HOperatorSetX.ReadImage( 'img/timg.jpg' ); var Width , Height = HOperatorSetX.GetImageSize( Image ); var WindowHandle = HOperatorSetX.OpenWindow( 0 , 0 , mainForm.picturebox.width , mainForm.picturebox.height , mainForm.picturebox.hwnd , "transparent", "" ); HOperatorSetX.DispObj( Image , WindowHandle ); mainForm.button.oncommand = function(id,event){ HOperatorSetX.SetColor( WindowHandle , "red" ); HOperatorSetX.SetDraw( WindowHandle , "margin" ); HOperatorSetX.SetLineWidth( WindowHandle , 2 ); //等待手工绘制区域,鼠标右键确认 var Row1 , Column1 , Row2 , Column2 = HOperatorSetX.DrawRectangle1( WindowHandle ); //显示区域 var Rectangle = HOperatorSetX.GenRectangle1( Row1 , Column1 , Row2 , Column2 ); HOperatorSetX.DispObj( Rectangle , WindowHandle ); //调用图像修复函数处理图像 Image = HOperatorSetX.InpaintingTexture( Image, Rectangle, 11, 40, 0, 'none', 0 ); HOperatorSetX.DispObj( Image , WindowHandle ); } mainForm.show(); return win.loopMessage();
1 个回复 | 最后更新于 2019-04-23
登录后方可回帖
保存处理好的图像到本地