コード例 #1
0
    # Vectors to send to the estimator
    features = []
    labels = []

    # Sample points
    sampleIds = get_random_points(model, SAMPLE_RATE)
    progressPoints = [int(len(sampleIds) / 10 * (k + 1)) for k in range(10)
                      ]  # just to get some progress meter action

    # Go through each sample, create features and label for that sample
    for j, sID in enumerate(sampleIds):
        if j in progressPoints:  # print out some progress
            print("About {} percent of {} sample points processed.".format(
                (progressPoints.index(j) + 1) * 10, len(sampleIds)))
        if PATCH_METHOD == "order":
            samplePatch = create_patch(model, modelGraph, idArray, invIdArray,
                                       sID, ORDER)
        elif PATCH_METHOD == "size":
            samplePatch = create_patch_optimised(model, modelGraph, idArray,
                                                 invIdArray, sID, PATCH_SIZE)

        sampleFeatures = get_features(model, samplePatch, FEATURES,
                                      PCA_COMPONENTS, sID)
        sampleLabel = mapScalars.GetValue(sID)
        if PCA_COMPONENTS != None:
            sampleFeatures = sampleFeatures.flatten()
        features.append(sampleFeatures)
        labels.append(sampleLabel)

        if j in progressPoints:
            print(os.path.join(mapLocation, mapFilename))
            print("Got feature {}, labelled {} for this".format(
コード例 #2
0
scalars = vtk.vtkDoubleArray()
scalars.SetNumberOfValues(model.GetNumberOfPoints())

# For example, set all scalars to 1
for i in range(model.GetNumberOfPoints()):
    scalars.SetValue(i, 1)

# Make some patches at the landmarks, of a certain size
landmarkPatches = []
landmarkSize = 0
st = time.time()

# Iterative way
for i in landmarkIds:
    landmarkPatches.append(
        create_patch(model, modelGraph, idArray, invIdArray, i, landmarkSize))

t = time.time() - st

print("Generated {} landmark patches of size {} in {} seconds.".format(
    len(landmarkIds), landmarkSize, t))
print("Average patch generation time: {} seconds.".format(t /
                                                          len(landmarkIds)))
print(model.GetNumberOfPoints())

# Paint the patches
for i, patch in enumerate(landmarkPatches):
    actualLandmarkNo = LANDMARK_REGIONS[subBone][i]

    for point in patch:
        scalars.SetValue(point, 2)