Last active
February 5, 2021 19:50
-
-
Save hasithsura/b798c972448bed0b4fa0ab891f244d19 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
def spec_to_image(spec, eps=1e-6): | |
mean = spec.mean() | |
std = spec.std() | |
spec_norm = (spec - mean) / (std + eps) | |
spec_min, spec_max = spec_norm.min(), spec_norm.max() | |
spec_scaled = 255 * (spec_norm - spec_min) / (spec_max - spec_min) | |
spec_scaled = spec_scaled.astype(np.uint8) | |
return spec_scaled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment