Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8_generate_posmap_300WLP.py, tfrom matrix #77

Open
zqq-judy opened this issue Dec 6, 2020 · 0 comments
Open

8_generate_posmap_300WLP.py, tfrom matrix #77

zqq-judy opened this issue Dec 6, 2020 · 0 comments

Comments

@zqq-judy
Copy link

zqq-judy commented Dec 6, 2020

Hello!

Q1、In the 8_generate_posmap_300WLP.py file, does the following code perform affine transformation and calculate the tfrom matrix?

kpt = image_vertices[bfm.kpt_ind, :].astype(np.int32)
left = np.min(kpt[:, 0])
right = np.max(kpt[:, 0])
top = np.min(kpt[:, 1])
bottom = np.max(kpt[:, 1])
center = np.array([right - (right - left) / 2.0 ,bottom - (bottom - top) / 2.0])
old_size = (right - left + bottom - top)/2
size = int(old_size*1.5)
# random pertube. you can change the numbers
marg = old_size*0.1
t_xv = np.random.rand()*marg*2 - marg
t_y = np.random.rand()*marg*2 - marg
center[0] = center[0]+t_x; center[1] = center[1]+t_y
size = size*(np.random.rand()*0.2 + 0.9)
# crop and record the transform parameters
src_pts = np.array([[center[0]-size/2, center[1]-size/2], [center[0] - size/2, center[1]+size/2], [center[0]+size/2, center[1]-size/2]])
DST_PTS = np.array([[0, 0], [0, image_h - 1], [image_w - 1, 0]])
tform = skimage.transform.estimate_transform('similarity', src_pts, DST_PTS)

Q2、So how to calculate the inverse_tfrom matrix of the inverse affine transformation?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant