当前位置:网站首页>Wood extraction in Halcon
Wood extraction in Halcon
2022-07-07 01:16:00 【Ride the magic horse and ride the clouds】
requirement : Extract the wood section in the following figure and count

result :


Code :
* Read images
read_image(image,' The position of the picture in the computer ')
* Image to grayscale
rgb1_to_gray(image,grayimage)
* Threshold segmentation
threshold (grayimage, regions, 60, 255)
* Open operation
opening_rectangle1(regions,Cut,2,7)
* Break the disconnected area
connection(Cut,connectedregions)
* Area screening
select_shape (connectedregions, SelectedRegions, 'area', 'and', 391.24, 20056.3)
* Count the number of wood in the first part
count_obj(SelectedRegions,Number1)
* Area screening
select_shape (connectedregions, SelectedRegions1, 'area', 'and', 24334.9, 100000)
* Corrosion calculation
erosion_circle(SelectedRegions1,regionerosion1,7.5)
* Break the disconnected area
connection(regionerosion1,connectedregions1)
* Area screening
select_shape (connectedregions1, SelectedRegions2, 'area', 'and', 2707.36, 20000)
* Count the number of wood in the second part
count_obj(SelectedRegions2,Number2)
* Merge the first part and the second part
concat_obj(SelectedRegions,SelectedRegions2,objectsconcat)
* Count the total number of timber in the combined part
count_obj(objectsconcat,Number3)
The process :
- Use read_image command , Read the wood section picture into , Put it in Image variable .

2. Use rgb1_to_gray command , Convert color pictures into grayscale images .

3. Use threshold command , Separate the wood section from the background .

4. Use opening_rectangle1 Command to open .

5. Use connection Command to break the disconnected area .

notes : Visible from above , There is still a lot of wood sticking after the first shipment , Therefore, consider bonding the part ( Red and purple in the above figure ) With the non adhesive part ( Other colors ) Count separately , Then sum the two . As for why not do it step by step in the fourth step , By adjusting the opening_rectangle1 Operator related parameters will clearly segment all wood , The main reason is that after setting the parameters, the assembly will give the purple piece of wood in the upper right corner of the figure above “ corrosion ” excessive , It is impossible to distinguish between wood and noise ( As shown in the figure below ), The setting is too small to divide the wood perfectly , It's very inconvenient .

6. Use select_shape operator , Conduct the first screening of wood according to the area .

7、 Use count_obj operator , Count the number of timber in the first part as 15.
8、 adopt select_shape operator , Select the image of the second part of the wood according to the area .

9. adopt erosion_circle operator , Separate the Connected Wood .

10、 Use connection Break the disconnected area .

11、 Use select_shape operator , Filter and remove impurities according to the area characteristics .

12、 Use count_obj operator , Count the number of timber in the second part as 10.
13、 Combine the two .10+15 I.e. total timber .

14. About the total number of timber , Not necessarily in step 7、 step 12 Calculate twice and then sum , have access to count_obj Operator directly finds the total number of wood in the above figure , Either way .

边栏推荐
- UI control telerik UI for WinForms new theme - vs2022 heuristic theme
- Atomic in golang and CAS operations
- There is an error in the paddehub application
- A brief history of deep learning (I)
- Taro中添加小程序 “lazyCodeLoading“: “requiredComponents“,
- Dell笔记本周期性闪屏故障
- 树莓派/arm设备上安装火狐Firefox浏览器
- Deeply explore the compilation and pile insertion technology (IV. ASM exploration)
- [Niuke] [noip2015] jumping stone
- Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
猜你喜欢

ARM裸板调试之JTAG原理

第七篇,STM32串口通信编程

pytorch之数据类型tensor
![[Niuke] [noip2015] jumping stone](/img/9f/b48f3c504e511e79935a481b15045e.png)
[Niuke] [noip2015] jumping stone

系统休眠文件可以删除吗 系统休眠文件怎么删除

Analysis of mutex principle in golang
![[case sharing] basic function configuration of network loop detection](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[case sharing] basic function configuration of network loop detection
![[batch dos-cmd command - summary and summary] - string search, search, and filter commands (find, findstr), and the difference and discrimination between find and findstr](/img/4a/0dcc28f76ce99982f930c21d0d76c3.png)
[batch dos-cmd command - summary and summary] - string search, search, and filter commands (find, findstr), and the difference and discrimination between find and findstr

第五篇,STM32系统定时器和通用定时器编程
![[Niuke] b-complete square](/img/bd/0812b4fb1c4f6217ad5a0f3f3b8d5e.png)
[Niuke] b-complete square
随机推荐
The difference between spin and sleep
[牛客] B-完全平方数
Part IV: STM32 interrupt control programming
The cost of returning tables in MySQL
golang中的Mutex原理解析
Taro 小程序开启wxml代码压缩
Installation and testing of pyflink
from .cv2 import * ImportError: libGL.so.1: cannot open shared object file: No such file or direc
实现mysql与ES的增量数据同步
批量获取中国所有行政区域经边界纬度坐标(到县区级别)
HMM notes
Deep learning framework TF installation
Oracle:CDB限制PDB资源实战
Openjudge noi 1.7 08: character substitution
BFS realizes breadth first traversal of adjacency matrix (with examples)
Case development of landlord fighting game
NEON优化:性能优化经验总结
Cause of handler memory leak
Explain in detail the matrix normalization function normalize() of OpenCV [norm or value range of the scoped matrix (normalization)], and attach norm_ Example code in the case of minmax
SuperSocket 1.6 创建一个简易的报文长度在头部的Socket服务器