Code Monkey home page Code Monkey logo

Comments (5)

LSnyd avatar LSnyd commented on May 16, 2024 1

I just wrote my own function:

`def create_sseg_file(gemms, labels, export_name_sseg):
gemmlabels = {}
classes = len(np.unique(labels))
totaledges = len(gemms)
sseg = np.zeros([ totaledges, classes])
for i, edges in enumerate(gemms):
alllabels = []
for edge in range(len(edges)):
lookupEdge = edges[edge]
label = labels[lookupEdge]
alllabels.append(label)
gemmlabels[i] = alllabels

for i, edges in enumerate(gemms):
        gemmlab = gemmlabels[i]
        uniqueValues, counts = np.unique(gemmlab, return_counts=True)
        for j, label in enumerate(uniqueValues):
            weight = 0.125*counts[j]
            sseg[i][int(label) - 1] = weight
np.savetxt(export_name_seseg, sseg,  fmt='%1.6f')`

You can get the "gemms" from


def get_gemm_edges(faces, export_name_edges):
    
#    gemm_edges: array (#E x 4) of the 4 one-ring neighbors for each edge
#    sides: array (#E x 4) indices (values of: 0,1,2,3) indicating where an edge is in the gemm_edge #    entry of the 4 neighboring edges
#    for example edge i -> gemm_edges[gemm_edges[i], sides[i]] == [i, i, i, i]
 
    edge_nb = []
    edge2key = dict()
    edges = []
    edges_count = 0
    nb_count = []
    for face_id, face in enumerate(faces):
        faces_edges = []
        for i in range(3):
            cur_edge = (face[i], face[(i + 1) % 3])
            faces_edges.append(cur_edge)
        for idx, edge in enumerate(faces_edges):
            edge = tuple(sorted(list(edge)))
            faces_edges[idx] = edge
            if edge not in edge2key:
                edge2key[edge] = edges_count
                edges.append(list(edge))
                edge_nb.append([-1, -1, -1, -1])
                nb_count.append(0)
                edges_count += 1
        for idx, edge in enumerate(faces_edges):
            edge_key = edge2key[edge]
            edge_nb[edge_key][nb_count[edge_key]] = edge2key[faces_edges[(idx + 1) % 3]]
            edge_nb[edge_key][nb_count[edge_key] + 1] = edge2key[faces_edges[(idx + 2) % 3]]
            nb_count[edge_key] += 2
    np.savetxt(export_name_edges, edges, fmt='%i')
    return edge_nb, edges

from meshcnn.

shirleyxy avatar shirleyxy commented on May 16, 2024

I have the same problem. Have you solved this problem?

from meshcnn.

yuvaramsingh94 avatar yuvaramsingh94 commented on May 16, 2024

hi @LSnyd , i like to know about how successful was your experiment with newly generated seseg file . i also like to know how to generate a new .seg file and what its content represent . i assume in .seg file, each row represent a vertex and number represent the class id. so far i am planning to generate .seg file by using paraview tool to save group of points into .csv file and then assign class id and append them in .seg file . is my workflow correct or do you have any better way to do the labeling.

from meshcnn.

LSnyd avatar LSnyd commented on May 16, 2024

Hi there,
I received the same results as provided in the example data, so it seems like that it is working.

I just worked with Blender to create the segmentations. Then I exported the .eseg file from there and create the seseg file with the script above.

from meshcnn.

yuvaramsingh94 avatar yuvaramsingh94 commented on May 16, 2024

Hi @LSnyd
can you share the steps to create .seg file using blender . i have not used blender yet. is there a way to directly export .seg file from blender?.
thanks

from meshcnn.

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.