這個是自己寫的一個圖片轉(zhuǎn)換成透明格式的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格式就可以了,這用作圖標(biāo),改背景有的用
本文來自博客園,作者:七星落地,轉(zhuǎn)載請注明原文鏈接:http://www.rzrgm.cn/dwx-bzdcxy/p/18576621
浙公網(wǎng)安備 33010602011771號