Question
How to modify the program to create a sequence of pictures converging to a white Sierpinski triangle on a black background. from scipy import misc
How to modify the program to create a sequence of pictures converging to a white Sierpinski triangle on a black background.
from scipy import misc import matplotlib.pyplot as plt import scipy pic=scipy.misc.ascent() m=scipy.misc.ascent()
for x in range(0,512,1): for y in range(0,512,1): pic[x,y]=255
a1=0.5 b1=0.0 e1=0 c1=0 d1=0.5 f1=0 a2=-0.5 b2=-0.25 e2=500 c2=0.5 d2=-0.25 f2=0 a3=0.75 b3=0.0 e3=62 c3=0 d3=0.75 f3=62 a4=0 b4=-0.25 e4=250 c4=-0.5 d4=-0.25 f4=500
misc.imsave('ascent'+str(0)+'.png',pic) for z in range(4): # pic = scipy.misc.imread('outputimage'+str(z)+'.png','l') for x in range(0,512,1): for y in range(0,512,1): m[x,y]=0
for x in range(0,512,1): for y in range(0,512,1): if pic[x,y]==255 or pic[x,y]==180 or pic[x,y]==150or pic[x,y]==120: m[int(a1*x+b1*y+e1),int(c1*x+d1*y+f1)]=255 m[int(a2*x+b2*y+e2),int(c2*x+d2*y+f2)]=180 m[int(a3*x+b3*y+e3),int(c3*x+d3*y+f3)]=150 m[int(a4*x+b4*y+e4),int(c4*x+d4*y+f4)]=120 pic[:]=m[:] plt.gray() misc.imsave('outputimage.png',pic)
plt.imshow(pic) plt.show()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started