Course Solutions Uncategorized (Solved) : Modify Program Create Sequence Pictures Converging White Sierpinski Triangle Black Backgro Q27306585 . . . .

(Solved) : Modify Program Create Sequence Pictures Converging White Sierpinski Triangle Black Backgro Q27306585 . . . .

 

How to modify the program to create a sequence of picturesconverging to a white Sierpinski triangle on a blackbackground.

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]==150orpic[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()

Expert Answer


An answer will be send to you shortly. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Solved) : 2 Write Matlab Program Uses Newton S Method Find Solution Following Nonlinear System 2123 Q29138901 . . . .(Solved) : 2 Write Matlab Program Uses Newton S Method Find Solution Following Nonlinear System 2123 Q29138901 . . . .

How can I using MATLAB to answer that question<br/><img src="https://media.cheggcdn.com/media%2Fc9e%2Fc9e940ee-1603-430d-ba32-f4ef57637bd8%2Fimage" alt="2. Write a Matlab program that uses Newtons method to find a solution to the following nonlinear system 2123 3-4