这个是自己写的一个图片转换成透明格式的halcon程序
1 read_image (VoiceOcr, 'D:/Qtprogram/Videographicsitem/iconsA/halconProcess/voice_ocr -2.jpg') 2 3 count_channels (VoiceOcr, Channels) 4 if(Channels==3) 5 decompose3 (VoiceOcr, Image1, Image2, Image3) 6 7 threshold(Image3, Region2, 200, 255) 8 connection(Region2,ConnectedRegion2) 9 select_shape (ConnectedRegion2, SelectedRegions2, 'area', 'and', 500, 9999999999) 10 11 compose3 (Image3, Image3, Image3, MultiChannelImage) 12 reduce_domain(MultiChannelImage,SelectedRegions2, ImageReduced2) 13 14 Image3 := ImageReduced2 15 16 compose4 (Image3, Image3, Image3, Image3, MultiChannelImage) 17 write_image (MultiChannelImage, 'tiff', 0, 'D:/Qtprogram/Videographicsitem/iconsA/halconProcess/voice_3') 18 19 *compose3 (Image3, Image3, Image3, MultiChannelImage) 20 *write_image (MultiChannelImage, 'png', 0, 'D:/Qtprogram/Videographicsitem/iconsA/halconProcess/voice_1K') 21 stop() 22 elseif(Channels==4) 23 decompose4 (VoiceOcr, Image1, Image2, Image3,Image4) 24 compose4 (Image3, Image3, Image3, Image3, MultiChannelImage) 25 write_image (MultiChannelImage, 'tiff', 0, 'D:/Qtprogram/Videographicsitem/iconsA/halconProcess/voice_1') 26 endif
本意是先拆分图片从3通道在到单通道,选择自己需要部分,
在合成4通道图片,透明图片是tiff写入的,然后在重命名改成png格式就可以了,这用作图标,改背景有的用
本文来自博客园,作者:七星落地,转载请注明原文链接:https://www.cnblogs.com/dwx-bzdcxy/p/18576621