日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HALCON示例程序color_fuses_lut_trans.hdev通过颜色对保险丝进行分类

發(fā)布時(shí)間:2023/12/10 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HALCON示例程序color_fuses_lut_trans.hdev通过颜色对保险丝进行分类 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

HALCON示例程序color_fuses_lut_trans.hdev通過顏色對(duì)保險(xiǎn)絲進(jìn)行分類

示例程序源碼(加注釋)

  • 關(guān)于顯示類函數(shù)解釋
    dev_update_off ()
  • 定義變量并初始化,這些變量都是下邊識(shí)別要用到的
    FuseColors := [‘Orange’,‘Red’,‘Blue’,‘Yellow’,‘Green’]
    DisplayColors := [‘coral’,‘red’,‘blue’,‘goldenrod’,‘forest green’]
    FuseTypes := [5,10,15,20,30]
  • 在hsv的H分量重Orange閾值為 10-30, Red閾值為 0-10以此類推
    HueRanges := [10,30,0,10,125,162,30,64,96,128]
    dev_close_window ()
    read_image (Image, ‘color/color_fuses_00’)
    dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
    set_display_font (WindowHandle, 14, ‘mono’, ‘true’, ‘false’)
  • create_color_trans_lut - 創(chuàng)建查找表,用于將圖像從RGB顏色空間轉(zhuǎn)換為任意顏色空間。
  • create_color_trans_lut(:: 轉(zhuǎn)化后的顏色空間,從什么顏色空間轉(zhuǎn)化,圖片位數(shù):顏色轉(zhuǎn)化句柄)
    create_color_trans_lut (‘hsv’, ‘from_rgb’, 8, ColorTransLUTHandle)
    for Count := 0 to 4 by 1
    read_image (Image, ‘color/color_fuses_0’ + Count)
    dev_display (Image)
    disp_message (WindowHandle, ‘color/color_fuses0’ + Count + ‘.png’, ‘window’, 12, 512, ‘black’, ‘true’)
    • 下邊兩句話是將rgb圖像轉(zhuǎn)化到HSV空間。與上一篇轉(zhuǎn)化不一樣。
      decompose3 (Image, Red, Green, Blue)
    • apply_color_trans_lut - 使用預(yù)生成的查找表進(jìn)行顏色空間轉(zhuǎn)換。
    • apply_color_trans_lut(圖1,圖2,圖3:圖像結(jié)果1,圖像結(jié)果2,圖像結(jié)果3:顏色轉(zhuǎn)化句柄 ?
      apply_color_trans_lut (Red, Green, Blue, Hue, Saturation, Intensity, ColorTransLUTHandle)
    • 下邊的這些算子與上一篇寫的就是一樣的了。
      threshold (Saturation, Saturated, 60, 255)
      reduce_domain (Hue, Saturated, HueSaturated)
      Output := []
      for Fuse := 0 to |FuseTypes| - 1 by 1
      threshold (HueSaturated, CurrentFuse, HueRanges[Fuse * 2], HueRanges[Fuse * 2 + 1])
      connection (CurrentFuse, CurrentFuseConn)
      fill_up (CurrentFuseConn, CurrentFuseFill)
      select_shape (CurrentFuseFill, CurrentFuseSel, ‘a(chǎn)rea’, ‘a(chǎn)nd’, 6000, 20000)
      area_center (CurrentFuseSel, FuseArea, Row1, Column1)
      dev_set_color (‘magenta’)
      for i := 0 to |FuseArea| - 1 by 1
      disp_message (WindowHandle, FuseColors[Fuse] + ’ ’ + FuseTypes[Fuse] + ’ Ampere’, ‘image’, Row1[i] + 40, Column1[i] - 100, DisplayColors[Fuse], ‘true’)
      endfor
      Output := [Output,FuseColors[Fuse] + ’ Fuses: ’ + |FuseArea|]
      endfor
      disp_message (WindowHandle, Output, ‘window’, -1, -1, DisplayColors, ‘true’)
      disp_continue_message (WindowHandle, ‘black’, ‘true’)
      stop ()
      endfor
      dev_update_on ()
      dev_close_window ()

處理思路

這個(gè)例子是將三通道的RGB圖像轉(zhuǎn)化到HSV空間進(jìn)行分割的例子,使用 create_color_trans_lut、decompose3 、apply_color_trans_lut三個(gè)算子實(shí)現(xiàn)RGB圖像轉(zhuǎn)化到HSV空間作用,使用HSV空間內(nèi)區(qū)域特征更加明顯的特點(diǎn)進(jìn)行分割。與上一篇不一樣的地方就在這個(gè)空間轉(zhuǎn)換是利用轉(zhuǎn)換查找表的形式進(jìn)行的。

后記

大家有什么問題可以向我提問哈,我看到了第一時(shí)間回復(fù),希望在學(xué)習(xí)的路上多多結(jié)交良師益友。

總結(jié)

以上是生活随笔為你收集整理的HALCON示例程序color_fuses_lut_trans.hdev通过颜色对保险丝进行分类的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。