Code Monkey home page Code Monkey logo

Comments (1)

Kiord avatar Kiord commented on July 4, 2024

I am assuming your mesh only contains vertex colors ? (Else you would already have your texture)
If so you can project the vertex colors in the texture space and interpolate between them to recreate a texture.

import numpy as np
import cv2
from scipy.interpolate import griddata
 
def compute_interpolation_map(shape, tcoords, values):
    points = (tcoords * np.asarray(shape)[None, :]).astype(np.int32)
    x = np.arange(shape[0])
    y = np.flip(np.arange(shape[1]))
    X, Y = np.meshgrid(x, y)
    res = griddata(points, values, (X, Y),  method='cubic')
    res[np.isnan(res)] = 0
    return res

tcoords = ... # you already have them
vertex_colors = ... # I assume you already have them
image_size = (512, 512) # create a 512 x 512 texture
texture_map = compute_interpolation_map(image_size, tcoords, vertex_colors) 
cv2.imwrite(image_path, texture_map)

from trimesh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.