code: def map_texture(
      src_image,
      src_vertices,
      dst_vertices,
      dst_triangle_buffer,
      triangles,
      h,
      w,
      c=3,
      mapping_type="bilinear",
  ):
      """
      Args:
          triangles: 3 x ntri
  
          # src
          src_image: height x width x nchannels
          src_vertices: 3 x nver
  
          # dst
          dst_vertices: 3 x nver
          dst_triangle_buffer: height x width. the triangle index of each pixel in dst image
  
      Returns:
          dst_image: height x width x nchannels
  
      """
      [sh, sw, sc] = src_image.shape
      dst_image = np.zeros((h, w, c))
      for y in range(h):
          for x in range(w):
              tri_ind = dst_triangle_buffer[y, x]
              if tri_ind < 0:  # no tri in dst image
                  continue
              # if src_triangles_vis[tri_ind]: # the corresponding triangle in src image is invisible
              #   continue
  
              # then. For this triangle index, map corresponding pixels(in triangles) in src image to dst image
              # Two Methods:
              # M1. Calculate the corresponding affine matrix from src triangle to dst triangle. Then find the corresponding src position of this dst pixel.
              # -- ToDo
              # M2. Calculate the relative position of three vertices in dst triangle, then find the corresponding src position relative to three src vertices.
              tri = triangles[:, tri_ind]
              # dst weight, here directly use the center to approximate because the tri is small
              # if tri_ind < 366:
              # print tri_ind
              w0, w1, w2 = get_point_weight(
                  [x, y], dst_vertices[:2, tri]
              )
              # else:
              #     w0 = w1 = w2 = 1./3
              # src
              src_texel = (
                  w0 * src_vertices[:2, tri[0]]
                  + w1 * src_vertices[:2, tri[1]]
                  + w2 * src_vertices[:2, tri[2]]
              )  #
              #
              if (
                  src_texel[0] < 0
                  or src_texel[0] > sw - 1
                  or src_texel[1] < 0
                  or src_texel[1] > sh - 1
              ):
                  dst_image[y, x, :] = 0
                  continue
              # As the coordinates of the transformed pixel in the image will most likely not lie on a texel, we have to choose how to
              # calculate the pixel colors depending on the next texels
              # there are three different texture interpolation methods: area, bilinear and nearest neighbour
              # print y, x, src_texel
              # nearest neighbour
              if mapping_type == "nearest":
                  dst_image[y, x, :] = src_image[
                      int(round(src_texel[1])),
                      int(round(src_texel[0])),
                      :,
                  ]
              # bilinear
              elif mapping_type == "bilinear":
                  # next 4 pixels
                  ul = src_image[
                      int(np.floor(src_texel[1])),
                      int(np.floor(src_texel[0])),
                      :,
                  ]
                  ur = src_image[
                      int(np.floor(src_texel[1])),
                      int(np.ceil(src_texel[0])),
                      :,
                  ]
                  dl = src_image[
                      int(np.ceil(src_texel[1])),
                      int(np.floor(src_texel[0])),
                      :,
                  ]
                  dr = src_image[
                      int(np.ceil(src_texel[1])),
                      int(np.ceil(src_texel[0])),
                      :,
                  ]
  
                  yd = src_texel[1] - np.floor(src_texel[1])
                  xd = src_texel[0] - np.floor(src_texel[0])
                  dst_image[y, x, :] = (
                      ul * (1 - xd) * (1 - yd)
                      + ur * xd * (1 - yd)
                      + dl * (1 - xd) * yd
                      + dr * xd * yd
                  )
  
      return dst_image
  
imports: import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: map_texture(src_image, src_vertices, dst_vertices, dst_triangle_buffer, triangles, h, w, c, mapping_type) and returns: dst_image