mirror of
				https://github.com/stevenrobertson/cuburn.git
				synced 2025-10-30 17:00:48 -04:00 
			
		
		
		
	Use np.unwrap (same idea as monotonify())
This commit is contained in:
		| @ -347,8 +347,7 @@ class Palette(HunkOCode): | |||||||
|         # TODO: premultiply alpha or some nonsense like that? |         # TODO: premultiply alpha or some nonsense like that? | ||||||
|         y, u, v = np.array(cls.YUV * pal.T[:3]) |         y, u, v = np.array(cls.YUV * pal.T[:3]) | ||||||
|         uvr = np.hypot(u, v) |         uvr = np.hypot(u, v) | ||||||
|         uvt = np.arctan2(v, u) |         uvt = np.unwrap(np.arctan2(v, u)) | ||||||
|         cls.monotonify(uvt) |  | ||||||
|         return y, uvr, uvt, pal.T[3] |         return y, uvr, uvt, pal.T[3] | ||||||
|  |  | ||||||
|     @classmethod |     @classmethod | ||||||
| @ -359,13 +358,6 @@ class Palette(HunkOCode): | |||||||
|         # Ensure Fortran order so that the memory gets laid out correctly |         # Ensure Fortran order so that the memory gets laid out correctly | ||||||
|         return np.array([r, g, b, a], order='F').T |         return np.array([r, g, b, a], order='F').T | ||||||
|  |  | ||||||
|     @staticmethod |  | ||||||
|     def monotonify(uvt): |  | ||||||
|         """Eliminate sign-flips in an array of radian angles (in-place).""" |  | ||||||
|         diff = np.diff(uvt) |  | ||||||
|         for i in np.nonzero(np.abs(diff) > np.pi)[0]: |  | ||||||
|             uvt[i:] -= np.sign(diff[i]) * 2 * np.pi |  | ||||||
|  |  | ||||||
|     modes = ['hsv', 'yuv', 'yuvpolar'] |     modes = ['hsv', 'yuv', 'yuvpolar'] | ||||||
|     decls = "surface<void, cudaSurfaceType2D> flatpal;\n" |     decls = "surface<void, cudaSurfaceType2D> flatpal;\n" | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Steven Robertson
					Steven Robertson