# one-star image from matplotlib import pyplot as plt import numpy as np star="s85" xcent=10 ycent=10 radius=5 r_backgr=100 g_backgr=100 b_backgr=100 infile=open("/content/drive/MyDrive/data/star_images/"+star+".pnm") datalist=infile.readlines() infile.close() n=len(datalist) del datalist[0:4] npdatalist=np.array(datalist) datalist1=npdatalist.reshape(400,3) r=[] g=[] b=[] i=0 while i < 400: r.append(int(datalist1[i][0])) g.append(int(datalist1[i][1])) b.append(int(datalist1[i][2])) i+=1 npr=np.array(r) npg=np.array(g) npb=np.array(b) r1=npr.reshape(20,20) g1=npg.reshape(20,20) b1=npb.reshape(20,20) px=range(20) for j in range(20): pd=r1[j] plt.plot(px,pd) px1=[0,xcent-radius-1,xcent-radius,xcent-radius+1,xcent-1,xcent,xcent+1,xcent+radius-1,xcent+radius,xcent+radius+1,19] pd1=[r_backgr,r_backgr,r_backgr+20,r_backgr,r_backgr,r_backgr+50,r_backgr,r_backgr,r_backgr+20,r_backgr,r_backgr] plt.plot(px1,pd1,color="k",linewidth=2) plt.show() py=range(20) for i in range(20): pd=[] for j in range(20): pd.append(r1[j][i]) plt.plot(py,pd) py1=[0,ycent-radius-1,ycent-radius,ycent-radius+1,ycent-1,ycent,ycent+1,ycent+radius-1,ycent+radius,ycent+radius+1,19] pd1=[r_backgr,r_backgr,r_backgr+20,r_backgr,r_backgr,r_backgr+50,r_backgr,r_backgr,r_backgr+20,r_backgr,r_backgr] plt.plot(py1,pd1,color="k",linewidth=2) plt.show() maxp=140 for j in range(20): for i in range(20): if r1[j][i] > maxp: r1[j][i] = maxp if g1[j][i] > maxp: g1[j][i] = maxp if b1[j][i] > maxp: b1[j][i] = maxp px=range(20) for j in range(20): pd_r=r1[j] for j in range(20): pd_g=g1[j] for j in range(20): pd_b=b1[j] px1=[0,19] pd1_r=[r_backgr,r_backgr] pd1_g=[g_backgr,g_backgr] pd1_b=[b_backgr,b_backgr] fig = plt.figure() ax = fig.add_subplot(3, 1, 1) for j in range(20): pd=r1[j] ax.plot(px, pd) ax.plot(px1,pd1_r,color="k",linewidth=2) ax = fig.add_subplot(3, 1, 2) for j in range(20): pd=g1[j] ax.plot(px, pd) ax.plot(px1,pd1_g,color="k",linewidth=2) ax = fig.add_subplot(3, 1, 3) for j in range(20): pd=b1[j] ax.plot(px, pd) ax.plot(px1,pd1_b,color="k",linewidth=2) plt.show()