def construct(self): self.add(Image_coordinate_system(downsampled=True)) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D k_math = FourierMathJuggling() k_math.k_from_real_in_old_woman() # has a 601x601 resolution pixels = k_math.get_pixels() img_in_real = k_math.get_real_in() self.cut_off_the_top = 170 img_kamp, img_kph = k_math.get_amp_and_ph_DOWNSAMPLED( cut_off_the_top=self.cut_off_the_top ) # here we have a cut_off_the_top, e.g. 2 pixels_DOWNSAMPLED = k_math.get_pixels_DOWNSAMPLED() k_disp = KSpace(pixel_len=pixels_DOWNSAMPLED) k_disp.overshoot_factor = 1.8 k_disp.fill_k_space_updater(img_kamp, new_amp_max=True) k_disp.set_shade_in_3d(True) self.add(k_disp) k_disp.set_magic_gauss(0, sigma=0.9, mode="lowpass") real_in = ImageMobject(np.uint8(img_in_real)).scale(1.5) real_in.to_edge(UL) real_text_in = TextMobject("Input").next_to(real_in, DOWN) self.add_fixed_in_frame_mobjects(real_in, real_text_in) img_out_real = k_math.get_real_out() real_out = ImageMobject(np.uint8(img_out_real)).scale(1.5) real_out.to_edge(UR) real_text = TextMobject("Real-Space").next_to(real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) self.play(Write(k_disp.magic_plane), rate_func=linear, run_time=2.5)
def construct(self): self.add(Image_coordinate_system(downsampled=True)) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D k_math = FourierMathJuggling() k_math.k_from_real_in_old_woman() # has a 601x601 resolution pixels = k_math.get_pixels() img_in_real = k_math.get_real_in() real_in = ImageMobject(np.uint8(img_in_real)).scale(1.5) real_in.to_edge(UL) real_text_in = TextMobject("Input").next_to(real_in, DOWN) self.add_fixed_in_frame_mobjects(real_in, real_text_in) self.cut_off_the_top = 170 img_kamp, img_kph = k_math.get_amp_and_ph_DOWNSAMPLED( cut_off_the_top=self.cut_off_the_top ) # here we have a cut_off_the_top, e.g. 2 pixels_DOWNSAMPLED = k_math.get_pixels_DOWNSAMPLED() k_disp = KSpace(pixel_len=pixels_DOWNSAMPLED) k_disp.overshoot_factor = 1.8 k_disp.fill_k_space_updater(img_kamp, new_amp_max=True) k_disp.set_shade_in_3d(True) self.add(k_disp) print(pixels_DOWNSAMPLED) img_out_real = k_math.get_real_out() real_out = ImageMobject(np.uint8(img_out_real)).scale(1.5) real_out.to_edge(UR) real_text = TextMobject("Real-Space").next_to(real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) def apply_filter(mob): val = queenstracker.get_value() #k_math.apply_transformations(val,sigma=0.05,mode="lowpass") #k_disp.set_magic_gauss(val,sigma=0.9, mode="lowpass") k_math.apply_transformations(val, sigma=0.2, mode="highpass") k_disp.set_magic_gauss(val, sigma=0.9, mode="highpass") img_kamp, img_kph = k_math.get_amp_and_ph_DOWNSAMPLED( cut_off_the_top=self.cut_off_the_top) k_disp.fill_k_space_updater(img_kamp) print("animating") mob.set_shade_in_3d(True) img_real = k_math.get_real_out() real_out.become( ImageMobject(np.uint8(img_real)).scale(1.5).to_edge(UR)) return mob queenstracker = ValueTracker(0) end_val = 0.99 self.play(queenstracker.increment_value, end_val, UpdateFromFunc(k_disp, apply_filter), rate_func=lambda t: there_and_back(t), run_time=12) print("end") self.wait(2) print("end")
def construct(self): self.add(Image_coordinate_system(zoomed=True)) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D k_math = FourierMathJuggling() k_math.k_from_real_image("milkeyway_noise.png") # has a 601x601 resolution pixels = k_math.get_pixels() img_in_real = k_math.get_real_in() real_in = ImageMobject(np.uint8(img_in_real)).scale(1.5) real_in.to_edge(UL) real_text_in = TextMobject("Input").next_to(real_in, DOWN) self.add_fixed_in_frame_mobjects(real_in, real_text_in) img_kamp, img_kph = k_math.get_amp_and_ph_ZOOMED() # here we have a cut_off_the_top, e.g. 2 pixels_ZOOMED = k_math.get_pixels_ZOOMED() k_disp = KSpace(pixel_len=pixels_ZOOMED) k_disp.overshoot_factor = 1.8 k_disp.fill_k_space_updater(img_kamp, new_amp_max=True) k_disp.set_shade_in_3d(True) self.add(k_disp) img_out_real = k_math.get_real_out() real_out = ImageMobject(np.uint8(img_out_real)).scale(1.5) real_out.to_edge(UR) real_text = TextMobject("Real-Space").next_to(real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) val0 = k_math.img_k_space[10:297, 300] val1 = k_math.img_k_space[304:580, 300] valx= val0.deepcopy() valy= val1.deepcopy() self.wait(2) def amp_tansformer(mob): fa=queenstracker.get_value() k_math.img_k_space[10:297, 300] = valx * (1 - fa) k_math.img_k_space[304:580, 300] = valy * (1 - fa) img_kamp, img_kph = k_math.get_amp_and_ph_ZOOMED() k_disp.fill_k_space_updater(img_kamp) print("animating") mob.set_shade_in_3d(True) img_real = k_math.get_real_out() real_out.become(ImageMobject(np.uint8(img_real)).scale(1.5).to_edge(UR)) return mob queenstracker = ValueTracker(0) end_val = 0.95 self.play(queenstracker.increment_value, end_val, UpdateFromFunc(k_disp, amp_tansformer), rate_func=linear, run_time=5) self.wait(2) print("end")
def construct(self): self.add(Image_coordinate_system(zoomed=True)) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D k_math = FourierMathJuggling() k_math.k_from_real_in_old_woman() # has a 601x601 resolution pixels = k_math.get_pixels() img_in_real = k_math.get_real_in() real_in = ImageMobject(np.uint8(img_in_real)).scale(1.5) real_in.to_edge(UL) real_text_in = TextMobject("Input").next_to(real_in, DOWN) self.add_fixed_in_frame_mobjects(real_in, real_text_in) img_kamp, img_kph = k_math.get_amp_and_ph_ZOOMED( ) # here we have a cut_off_the_top, e.g. 2 pixels_ZOOMED = k_math.get_pixels_ZOOMED() k_disp = KSpace(pixel_len=pixels_ZOOMED) k_disp.overshoot_factor = 1.8 k_disp.fill_k_space_updater(img_kamp, new_amp_max=True) k_disp.set_shade_in_3d(True) self.add(k_disp) img_out_real = k_math.get_real_out() real_out = ImageMobject(np.uint8(img_out_real)).scale(1.5) real_out.to_edge(UR) real_text = TextMobject("Real-Space").next_to(real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) pos = (300, 298) val0 = k_math.img_k_space[pos] def amp_tansformer(mob): k_math.img_k_space[pos] = val0 * (1 + 40 * queenstracker.get_value()) img_kamp, img_kph = k_math.get_amp_and_ph_ZOOMED() k_disp.fill_k_space_updater(img_kamp) print("animating") mob.set_shade_in_3d(True) img_real = k_math.get_real_out() real_out.become( ImageMobject(np.uint8(img_real)).scale(1.5).to_edge(UR)) return mob queenstracker = ValueTracker(0) end_val = 1 self.play(queenstracker.increment_value, end_val, UpdateFromFunc(k_disp, amp_tansformer), rate_func=lambda t: there_and_back(t), run_time=7) print("end")
def update_ampli(mob): k_math = FourierMathJuggling.k_from_preset_minimal( **postion_setting, amplitude=my_ampli_tracker.get_value()) mob.fill_k_space_updater(k_math.get_amp_k_only()) img_real = k_math.get_real_out() real_out.fill_real_space(pixels**2 * img_real) return mob
def construct(self): self.add(Image_coordinate_system(zoomed=True)) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D k_math = FourierMathJuggling() k_math.k_from_real_image("milkeyway.png") # has a 601x601 resolution pos = (296, 300) k2 = np.ones((601, 601)) k2[pos] = 255 * 601**2 / 5 k_math_2 = FourierMathJuggling(k2) # val0 = k_math.img_k_space[pos] # k_math.img_k_space[pos] = val0*30 pixels = k_math_2.get_pixels() # img_in_real2 = k_math_2.get_real_out() img_in_real2 = np.fromfunction(lambda i, j: 60 * np.sin(i / 601), (601, 601)) real_in = ImageMobject(np.uint8(img_in_real2)).scale(1.5) real_in.to_edge(UL) real_text_in = TextMobject("Input").next_to(real_in, DOWN) self.add_fixed_in_frame_mobjects(real_in, real_text_in) img_kamp, img_kph = k_math.get_amp_and_ph_ZOOMED( ) # here we have a cut_off_the_top, e.g. 2 pixels_ZOOMED = k_math.get_pixels_ZOOMED() k_disp = KSpace(pixel_len=pixels_ZOOMED) k_disp.overshoot_factor = 1.8 k_disp.fill_k_space_updater(img_kamp, new_amp_max=True) k_disp.set_shade_in_3d(True) self.add(k_disp) img_out_real = k_math.get_real_out() insg = img_out_real + img_in_real2 insg[insg < 0] = 0 insg[insg > 255] = 255 insg = np.uint8(insg) real_out = ImageMobject(np.uint8(insg)).scale(1.5) real_out.to_edge(UR) real_text = TextMobject("Real-Space").next_to(real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) from PIL import Image result = Image.fromarray((insg).astype(np.uint8)) result.save('out.png')
def construct(self): self.add(Image_coordinate_system()) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D k_math = FourierMathJuggling() k_math.k_from_real_in_from_star() pixels = k_math.get_pixels() k_disp = KSpace(pixel_len=pixels) img_kamp, img_kph = k_math.get_amp_and_ph() img_kamp[9, 9] = img_kamp[9, 9] / 4 #lower the center frequency a little k_disp.overshoot_factor = 1.5 k_disp.fill_k_space_updater(img_kamp, new_amp_max=True) k_disp.set_phase_flowers_updater(img_kph) k_disp.set_shade_in_3d(True) self.add(k_disp) # compare_Axis = Comp_axis(height=3).set_shade_in_3d() # compare_Axis.set_opacity(0.1) # self.add(compare_Axis) real_out = Realspace(pixel_len=pixels) img_real = k_math.get_real_out() real_out.fill_real_space(img_real) real_out.scale(9 / pixels * k_plane_size * 0.3).to_edge(UR) real_text = TextMobject("Real-Space").scale(0.75).next_to( real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) self.play(FadeIn(k_disp.flows), run_time=1) self.play(FadeOut(k_disp.flows))
def construct(self): k_math= FourierMathJuggling() k_math.k_from_real_in_old_woman() pixels=k_math.get_pixels() woman=k_math.get_real_in() print("yes") image_disp=Realspace(pixels) image_disp.fill_real_space(woman) self.add(image_disp) self.wait(2)
def construct(self): #self.add(Image_coordinate_system(downsampled=True)) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D k_math = FourierMathJuggling() k_math.k_from_real_in_from_star() k_math.img_k_space[9, 9] = k_math.img_k_space[9, 9] / 4 p = k_math.get_pixels() k_disp = KSpace(pixel_len=19) k_disp.overshoot_factor = 0.09 k_disp.amp_max = 1000 k_disp.fill_k_space_updater(k_math.get_amp_k_only()) k_disp.set_magic_gauss(0.8, sigma=0.9, mode="lowpass") k_disp.set_shade_in_3d(True) self.add(k_disp) self.wait()
def construct(self): self.add(Image_coordinate_system()) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D #math_preperation: k_math = FourierMathJuggling.k_from_preset_minimal(amplitude=255) pixels = k_math.get_pixels() k_disp = KSpace(pixel_len=pixels) img_kamp, img_kph = k_math.get_amp_and_ph() k_disp.amp_max = 255 k_disp.fill_k_space_updater(img_kamp) k_disp.set_shade_in_3d(True) self.add(k_disp) real_out = Realspace(pixel_len=pixels) img_real = k_math.get_real_out() real_out.fill_real_space(pixels**2 * img_real) ## why??? something with norm real_out.scale(9 / pixels * k_plane_size * 0.3).to_edge(UR) real_text = TextMobject("Real-Space").scale(0.75).next_to( real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) ##HERE STARTS THE LOOP: Order = [("LEFT", 3), ("LEFT", 1), ("UP", 1), ("UP", 3), ("DIAG", 2), ("UP", 0)] Order = [("LEFT", 1), ("LEFT", 3), ("UP", 3), ("UP", 1), ("UP", -1), ("DIAG", 2), ("DIAG", 1), ("UP", 0)] Order = [("LEFT", 1), ("UP", 0)] # Order= [("LEFT",3),("LEFT",1),("DIAG",2)] for o_step in range(0, len(Order)): postion_setting = { "preset_position": Order[o_step][0], "center_dist": Order[o_step][1] } #lift the amplitude def update_ampli(mob): k_math = FourierMathJuggling.k_from_preset_minimal( **postion_setting, amplitude=my_ampli_tracker.get_value()) mob.fill_k_space_updater(k_math.get_amp_k_only()) img_real = k_math.get_real_out() real_out.fill_real_space(pixels**2 * img_real) return mob start_val = 0 end_val = 255 my_ampli_tracker = ValueTracker(start_val) self.play(my_ampli_tracker.increment_value, end_val, UpdateFromFunc(k_disp, update_ampli), rate_func=linear, run_time=2.5) self.wait(2) start_val = 255 end_val = 0 my_ampli_tracker = ValueTracker(start_val) self.play(my_ampli_tracker.set_value, end_val, UpdateFromFunc(k_disp, update_ampli), rate_func=linear, run_time=1.5) self.wait(0.3) self.wait(2)
def construct(self): self.add(Image_coordinate_system()) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D #self.set_camera_orientation(phi=40 * DEGREES, theta=-60 * DEGREES) #TODO NO! k_math = FourierMathJuggling() FourierMathJuggling.k_from_preset_uniform(7) k_math.k_from_real_in_old_woman() # has a 600x600 resolution pixels = k_math.get_pixels() print("yes",pixels) img_kamp, img_kph = k_math.get_amp_and_ph_DOWNSAMPLED(self.down_sample_factor) pixels_DOWNSAMPLED = k_math.get_pixels_DOWNSAMPLED() k_disp = KSpace(pixel_len=pixels_DOWNSAMPLED) k_disp.overshoot_factor=1 k_disp.log10view=self.log10view k_disp.fill_k_space_updater(img_kamp,new_amp_max=True) #init wit new_amp_max ture k_disp.set_shade_in_3d(True) self.add(k_disp) print("yes",pixels_DOWNSAMPLED) compare_Axis = Comp_axis(height=3).set_shade_in_3d() compare_Axis.set_opacity(0.1) self.add(compare_Axis) img_out_real = k_math.get_real_out() real_out=ImageMobject(np.uint8(img_out_real)).scale(1.5) real_out.to_edge(UR) real_text = TextMobject("Real-Space").next_to(real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) img_in_real = k_math.get_real_in() real_in = ImageMobject(np.uint8(img_in_real)).scale(1.5) real_in.to_edge(UL) real_text_in = TextMobject("Input").next_to(real_in, DOWN) self.add_fixed_in_frame_mobjects(real_in, real_text_in) #HERE STARTS THE LOOP: ####change the phase def apply_filter(mob): val= queenstracker.get_value() #k_math.apply_transformations(val,sigma=0.05,mode="lowpass") #k_disp.set_magic_gauss(val,sigma=0.9, mode="lowpass") k_math.apply_transformations(val,sigma=0.9,mode="highpass") k_disp.set_magic_gauss(val,sigma=0.9, mode=234) img_kamp, img_kph =k_math.get_amp_and_ph_DOWNSAMPLED(self.down_sample_factor) k_disp.fill_k_space_updater(img_kamp) print("animating") mob.set_shade_in_3d(True) img_real = k_math.get_real_out() real_out.become(ImageMobject(np.uint8(img_real)).scale(1.5).to_edge(UR)) return mob queenstracker = ValueTracker(0) end_val=1 self.play(queenstracker.increment_value, end_val, UpdateFromFunc(k_disp, apply_filter), rate_func=linear,run_time=3) print("end") self.wait(2)
def construct(self): self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D #Order = [("LEFT", 1), ("LEFT", 7), ("DIAG",-3), ("UP", 0)] Order = ["LEFT", 1] for o_step in range(0, len(Order)): self.clear() self.add(Image_coordinate_system()) postion_setting = { "preset_position": Order[o_step][0], "center_dist": Order[o_step][1] } # math_preperation: k_math = FourierMathJuggling.k_from_preset_minimal(** postion_setting, amplitude=255) pixels = k_math.get_pixels() print(pixels) k_disp = KSpace(pixel_len=19) img_kamp, img_kph = k_math.get_amp_and_ph() k_disp.amp_max = 255 k_disp.fill_k_space_updater(img_kamp) k_disp.set_shade_in_3d(True) self.add(k_disp) real_out = Realspace(pixel_len=pixels) img_real = k_math.get_real_out() real_out.fill_real_space(pixels**2 * img_real) ## why??? something with norm real_out.scale(9 / pixels * k_plane_size * 0.3).to_edge(UR) real_text = TextMobject("Real-Space").scale(0.75).next_to( real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) self.wait(1) real_out_compare = Realspace(pixel_len=pixels) img_real_compare = deepcopy(img_real) real_out_compare.fill_real_space(pixels**2 * img_real_compare) real_out_compare.scale(9 / pixels * k_plane_size * 0.3).next_to( real_text, DOWN) self.add_fixed_in_frame_mobjects(real_out_compare) self.wait(1) # ##HERE STARTS THE LOOP: # ####change the phase def update_phase(mob): val = my_phase_tracker.get_value() k_math.phase_shift_single(val, **postion_setting) img_kamp, img_kph = k_math.get_amp_and_ph() mob.set_phase_flowers_updater(img_kph) mob.set_shade_in_3d(True) img_real = k_math.get_real_out() real_out.fill_real_space(pixels**2 * img_real) return mob my_phase_tracker = ValueTracker(0) for i in range(0, 4): self.play(my_phase_tracker.increment_value, 90, UpdateFromFunc(k_disp, update_phase), rate_func=linear) print("ye") self.wait(1)
def construct(self): self.add(Image_coordinate_system()) self.camera.frame_center.shift(2 * OUT) self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) # 2.5D k_math = FourierMathJuggling() k_math.k_from_real_in_from_star() pixels = k_math.get_pixels() k_disp = KSpace(pixel_len=pixels) img_kamp, img_kph = k_math.get_amp_and_ph() img_kamp[9, 9] = img_kamp[9, 9] / 4 #lower the center frequency a little k_disp.overshoot_factor = 1.5 k_disp.fill_k_space_updater(img_kamp, new_amp_max=True) k_disp.set_shade_in_3d(True) self.add(k_disp) # compare_Axis = Comp_axis(height=3).set_shade_in_3d() # compare_Axis.set_opacity(0.1) # self.add(compare_Axis) real_out = Realspace(pixel_len=pixels) img_real = k_math.get_real_out() real_out.fill_real_space(img_real) real_out.scale(9 / pixels * k_plane_size * 0.3).to_edge(UR) real_text = TextMobject("Real-Space").scale(0.75).next_to( real_out, DOWN) self.add_fixed_in_frame_mobjects(real_out, real_text) # ##HERE STARTS THE LOOP: def amp_grower(mob): val = queenstracker.get_value() #k_math.apply_transformations(val) k_math.apply_spiral_mask(val) img_kamp, img_kph = k_math.get_amp_and_ph() img_kamp[ 9, 9] = img_kamp[9, 9] / 4 # lower the center frequency a little k_disp.fill_k_space_updater(img_kamp) mob.set_shade_in_3d(True) img_real = k_math.get_real_out() real_out.fill_real_space(img_real) return mob queenstracker = ValueTracker(0) end_val = 25 self.play(queenstracker.increment_value, end_val, UpdateFromFunc(k_disp, amp_grower), rate_func=linear, run_time=15) print("ye") self.wait(1) end_val = 50 self.play(queenstracker.increment_value, end_val, UpdateFromFunc(k_disp, amp_grower), rate_func=linear, run_time=10) self.wait(1) end_val = 100 self.play(queenstracker.increment_value, end_val, UpdateFromFunc(k_disp, amp_grower), rate_func=linear, run_time=10)