Skip to content

Commit

Permalink
Merge pull request #724 from jabooth/tcoords_transforms
Browse files Browse the repository at this point in the history
add transforms for tcoords -> image coords
  • Loading branch information
jabooth committed Nov 16, 2016
2 parents 42fd7c4 + 63c0983 commit 20f6c90
Show file tree
Hide file tree
Showing 6 changed files with 22,412 additions and 12 deletions.
12 changes: 2 additions & 10 deletions menpo/shape/mesh/textured.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from menpo.shape import PointCloud
from menpo.transform import Scale
from menpo.transform import tcoords_to_image_coords

from ..adjacency import mask_adjacency_array, reindex_adjacency_array
from .base import TriMesh, grid_tcoords
Expand Down Expand Up @@ -162,15 +162,7 @@ def tcoords_pixel_scaled(self):
>>> tc_ps = texturedtrimesh.tcoords_pixel_scaled()
>>> pixel_values_at_tcs = texture.sample(tc_ps)
"""
scale = Scale(np.array(self.texture.shape)[::-1])
tcoords = self.tcoords.points.copy()
# flip the 'y' st 1 -> 0 and 0 -> 1, moving the axis to upper left
tcoords[:, 1] = 1 - tcoords[:, 1]
# apply the scale to get the units correct
tcoords = scale.apply(tcoords)
# flip axis 0 and axis 1 so indexing is as expected
tcoords = tcoords[:, ::-1]
return PointCloud(tcoords)
return tcoords_to_image_coords(self.texture.shape).apply(self.tcoords)

def from_vector(self, flattened):
r"""
Expand Down
1 change: 1 addition & 0 deletions menpo/transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from .groupalign.procrustes import GeneralizedProcrustesAnalysis
from .compositions import (scale_about_centre, rotate_ccw_about_centre,
shear_about_centre, transform_about_centre)
from .tcoords import image_coords_to_tcoords, tcoords_to_image_coords

0 comments on commit 20f6c90

Please sign in to comment.