![](https://img2022.cnblogs.com/blog/1502586/202204/1502586-20220408144553259-1998247799.png)
![](https://img2022.cnblogs.com/blog/1502586/202204/1502586-20220408144702803-2115662683.png)
在HDevelop中
read_image (Image, 'D:/bb/tu/11.png')
get_image_size (Image, Width, Height)
dev_open_window (10, 10, Width, Height, 'black', WindowHandle)
local_threshold (Image, Region, 'adapted_std_deviation', 'dark', [], [])
*局部阈值--适合不均匀照明-->渐变背景
*参数1:输入图像
*参数2:分割后的区域
*参数3:分割方法 'adapted_std_deviation'
*参数4:提取前景还是背景
dev_display(Region)
![](https://img2022.cnblogs.com/blog/1502586/202204/1502586-20220408144751287-202877313.png)
在QtCreator中
HObject ho_Image, ho_Region;
HTuple hv_Width, hv_Height, hv_WindowHandle;
ReadImage(&ho_Image, "D:/bb/tu/11.png");
GetImageSize(ho_Image, &hv_Width, &hv_Height);
SetWindowAttr("background_color","black");
OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle);
HDevWindowStack::Push(hv_WindowHandle);
LocalThreshold(ho_Image, &ho_Region, "adapted_std_deviation", "dark", HTuple(),
HTuple());
//局部阈值--适合不均匀照明-->渐变背景
//参数1:输入图像
//参数2:分割后的区域
//参数3:分割方法 'adapted_std_deviation'
//参数4:提取前景还是背景
if (HDevWindowStack::IsOpen())
DispObj(ho_Region, HDevWindowStack::GetActive());
![](https://img2022.cnblogs.com/blog/1502586/202204/1502586-20220408144935153-1028722646.png)
![](https://img2022.cnblogs.com/blog/1502586/202204/1502586-20220408144603859-119448148.png)