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

Question About Mask Rotation #220

Closed
Brian417-cup opened this issue Aug 29, 2023 · 3 comments
Closed

Question About Mask Rotation #220

Brian417-cup opened this issue Aug 29, 2023 · 3 comments

Comments

@Brian417-cup
Copy link

I noticed that you had a 90 degree rotation operation on the mask before doing the mask triangulation patch.

_mask = np.rot90(_mask, 3, ) # rotate to upright

And after I running your triangulation function, I found that if without this operation, it would not have obtained the correct result. I would like to know why this rotation operation is needed.

Here is initialization mask , my visualization results about rotation and withou rotation respectively:
mask
rotate
wo_rotate

@hjessmith
Copy link
Contributor

Hello @Brian417-cup,

I'm not entirely sure I understand your question. As you've already shown with your examples, if we don't rotate the mask then the resulting mesh is incorrectly oriented. That seems like one answer to your question, but I assume it is not the one you are after.

Could you please give me a little more context on what you mean and why you are asking this question?

@Brian417-cup
Copy link
Author

Okay, here are more details: regarding the triangulation process of the mask, I have separately take out the generated mesh function you provided:

def _generate_mesh(self) -> None:

and use the visualization function you provided to visualize the triangulation.:

def plot_mesh(vertices, triangles, pins_xy):

At the beginning, I didn't notice that the input mask needs to be rotated first and just make the input mask have same adjusted width and height. Therefore, I got was the incorrect result you saw above. Then, I find in your source code have a rotation operation above.

I wonder if the necessity of rotation operation is due to a process that transposes the image again during the subsequent triangulation process. Please forgive me for being a beginner in the field of graphics.

@hjessmith
Copy link
Contributor

In the Animated Drawings visualization code, the second dimension (the 'y' in [x, y, z]) cartesian coordinates) of a point defines its height. But when reading in an image using cv2, the resulting matrix has dimensions [nrows, ncols, nchannels]. Since the 'height' of a pixel in the image is determined by it's row, this information is contained in the first dimension.

IIRC, the rotation is necessary to account for the mismatch between these two representations.

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

2 participants