当前位置:网站首页>Halcon draw area into picture

Halcon draw area into picture

2022-06-24 14:08:00 Tingyi - flying bird

Draw the area into the picture ( grayscale )

The area color is white

public static HImage WriteRegion(HImage baseImg, HRegion wRegion)
{
    
    int nWidth, nHeight;
    baseImg.GetImageSize(out nWidth, out nHeight);
    HImage zeroImage = new HImage();
    zeroImage.GenImageConst("byte", nWidth, nHeight);
    zeroImage = zeroImage.PaintRegion(wRegion, (HTuple)255, "fill");
    
    return zeroImage;
}

Draw the area into the picture ( Color picture )

The color of the area can be RGB Component setting .

public static HImage GetRegionRGB(HImage baseImg, HRegion wRegion, int iR, int iG, int iB)
{
    
    HImage imgResult = baseImg.CopyImage();

    HImage imgR = new HImage();
    HImage imgB = new HImage();
    HImage imgG = new HImage();

    HRegion wBig = wRegion.DilationCircle(3.5);
    HRegion wInside = wRegion.DilationCircle(1.5);
    HRegion outRegion = wBig.Difference(wInside);

    imgR = imgResult.Decompose3(out imgG, out imgB);
    imgR = imgR.PaintRegion(outRegion, (HTuple)iR, "fill");
    imgG = imgG.PaintRegion(outRegion, (HTuple)iG, "fill");
    imgB = imgB.PaintRegion(outRegion, (HTuple)iB, "fill");

    imgResult = imgR.Compose3(imgG, imgB);

    return imgResult;
}
原网站

版权声明
本文为[Tingyi - flying bird]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241145157261.html