[ABCNet] Train your own model - Bezier curve flattening

[ABCNet trains its own model (1)]
[ABCNet trains its own model (2)]
[ABCNet trains its own model (3)]

Bezier Curve Flattening

The Bezier curve finally obtains the image we want through the interpolation method, which has been introduced in the previous article; here we only introduce the sampling method: this function implements Bezier sampling, and the understanding of flattening can refer to the
insert image description here
ring Leveling, except that continuous points are not used for interpolation here, but the sampling results are directly sent to the interpolation algorithm;

def _bezier_to_poly(self, bezier):
        # bezier to polygon, 20表示一条直线上采样点的个数,这个可以根据实际需求去设置,
        #直接影响是数值越大,代表你生成的拉平后图像分辨率越高,数值越小生成的图像分辨率会越小
        # 如果使用小分辨率的图像去插值变大,这个学图像的大家都知道会怎样,就不详细说了。
        u = np.linspace(0, 1, 20)
        bezier = bezier.reshape(2, 4, 2).transpose(0, 2, 1).reshape(4, 4)
        points = np.outer((1 - u) ** 3, bezier[:, 0]) \
            + np.outer(3 * u * ((1 - u) ** 2), bezier[:, 1]) \
            + np.outer(3 * (u ** 2) * (1 - u), bezier[:, 2]) \
            + np.outer(u ** 3, bezier[:, 3])
        points = np.concatenate((points[:, :2], points[:, 2:]), axis=0)

        return points

Guess you like

Origin blog.csdn.net/m0_37661841/article/details/109593249
Recommended