Formulating Image Outline Programmatically (Preferrably C#/C++ coding, or pseudo coding)

前端 未结 2 1525
生来不讨喜
生来不讨喜 2020-12-18 14:49

I would just like to ask for assistance to anyone on the logic, and much better sample code of formulating an image\'s outline.

To make it clearer, I\'m talking abo

相关标签:
2条回答
  • 2020-12-18 15:28

    One way is to use a general edge detection algorithm. For example, Sobel edge detection. However, it's not optimized for clean, antialiased, two-color images like the example below, so it produces a somewhat rough result. To better preserve the antialiasing, and get a smooth result, I suggest the following algorithm:

    Image blurredImg = gaussianBlur(sourceImg, blurRadius = desiredOutlineWidth);
    const float sharpnessCoef = 0.1; // value may need tuning or may need to
                                     // depend on the blur radius
    Image dilatedImg = from blurredImg, map all pixels with
                       brightness > sharpnessCoef to white and
                       multiply the rest by 1 / sharpnessCoef
    Image smoothResult = subtract sourceImg from dilatedImg
    

    Example:

    edge detection

    0 讨论(0)
  • 2020-12-18 15:35

    Consider using image processing techniques, like this one:

    http://www.codeproject.com/KB/cs/Canny_Edge_Detection.aspx

    0 讨论(0)
提交回复
热议问题