halcon學習之顏色與紋理

*顏色分析
*在彩色圖像上進行分割區域,有時候更有優勢,如果目標物是顏色分明或者顏色相近的可以通過轉換到
*HSV和HSI進行處理,其中HSV分別代表:色調(Hue)、飽和度(Saturation)、純度(Value)
*HSI表示色調(Hue)、飽和度(Saturation)、亮度(Intensity)
*色調反應了人眼對顏色的感覺,如是紅色還是藍色
*飽和度反應了顏色中所含顏色數量的差別,如果紅色和粉紅就不同
*純度或者亮度反應了光線對顏色的影響程度、或者說顏色的密度如深灰和淺灰的差別

read_image (Image, 'F:/機器視覺/Halcon機器視覺算法原理與編程實戰/code/code/data/beads')
*把彩色圖片分爲三通道
decompose3 (Image, Red, Green, Blue)
sub_image (Blue, Red, ImageSub, 1, 128)
* sub_image (Red, Blue, ImageSub2, 1, 128)
* sub_image (Red, Green, ImageSub3, 1, 128)
sub_image (ImageSub, Green, ImageSub1, 1, 128)
threshold (ImageSub1, Regions, 0, 53)

*例子
read_image (Image1, 'F:/機器視覺/Halcon機器視覺算法原理與編程實戰/code/code/data/m105.jpg')
*將彩色圖片進行通道分離得到紅、綠、藍三通道圖像
decompose3 (Image1, Red, Green, Blue)
*將RGB三通道圖像轉化爲H(色調)、S(飽和度)、V(明度)圖像、
trans_from_rgb (Red, Green, Blue, ImageResultH, ImageResultS, ImageResultV, 'hsv')
*對飽和度圖像進行閾值處理,以此分割出高飽和度區域
threshold (ImageResultS, Regions1, 192, 255)
*分割區域
reduce_domain (ImageResultH, Regions1, ImageReduced)
*膨脹處理
dilation_circle (Regions1, RegionDilation, 3.5)
*開運算處理
opening_circle (RegionDilation, RegionOpening, 5.5)

文理分析

*紋理分析
read_image (Image2, 'F:/機器視覺/Halcon機器視覺算法原理與編程實戰/code/code/data/cloth')
*將彩色圖片進行通道分離得到紅、綠、藍三通道圖像
decompose3 (Image2, Red2, Green2, Blue2)
*將RGB三通道圖像轉化爲H(色調)、S(飽和度)、V(明度)圖像、
trans_from_rgb (Red2, Green2, Blue2, ImageResultH2, ImageResultS2, ImageResultV2, 'hsv')
*進行紋理檢測
texture_laws (ImageResultH2, ImageTexture, 'ls', 2, 7)
mean_image (ImageTexture, ImageMean, 11, 11)
threshold (ImageMean, Regions2, 60, 255)
connection (Regions2, ConnectedRegions)
area_center (ConnectedRegions, Area, Row, Column)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章