Last active
September 1, 2022 16:26
-
-
Save ThomasParistech/fec945b0a53eedad355fbda3f4e8804d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def get_up_mask(height: int, width: int) -> np.ndarray: | |
| """ | |
| Get the mask corresponding to the projection of the UP cubeface | |
| on the equirectangular image | |
| """ | |
| mask = np.zeros((height, width // 4), bool) | |
| # Get the mask above a single cubeface | |
| theta = sample_pixels(-np.pi/4, np.pi/4, width // 4) | |
| phi = -np.arctan(np.cos(theta)) | |
| phi_idx = ((phi/np.pi + 0.5) * height).astype(int) | |
| for i, j in enumerate(phi_idx): | |
| mask[:j, i] = True | |
| # Repeat 4 times and roll by a half-cubeface | |
| up_mask = np.tile(mask, 4) | |
| return np.roll(up_mask, width // 8, axis=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment