mirror of
https://github.com/helblazer811/ManimML.git
synced 2025-06-18 20:18:47 +08:00
Changed directory structure to accomodate examples as apposed to everything being a part of the core library. May need to rethink this in the future. Added some boilerplate for pip packaging to the .gitignore.
This commit is contained in:

committed by
Alec Helbling

parent
4eb5296c9c
commit
3be5c54d26
15
manim_ml/util.py
Normal file
15
manim_ml/util.py
Normal file
@ -0,0 +1,15 @@
|
||||
from manim import *
|
||||
import numpy as np
|
||||
|
||||
def construct_image_mobject(input_image, height=2.3):
|
||||
"""Constructs an ImageMobject from a numpy grayscale image"""
|
||||
# Convert image to rgb
|
||||
if len(input_image.shape) == 2:
|
||||
input_image = np.repeat(input_image, 3, axis=0)
|
||||
input_image = np.rollaxis(input_image, 0, start=3)
|
||||
# Make the ImageMobject
|
||||
image_mobject = ImageMobject(input_image, image_mode="RGB")
|
||||
image_mobject.set_resampling_algorithm(RESAMPLING_ALGORITHMS["nearest"])
|
||||
image_mobject.height = height
|
||||
|
||||
return image_mobject
|
Reference in New Issue
Block a user