Chengshi asked to change the map, because using the PIL package to convert the picture object into a numpy matrix, interception and processing is very fun and convenient, hereby recorded:
1 ImportNumPy as NP2 fromPILImportImage3 ImportMatplotlib.pyplot as Plt4 5img = Image.open ('./7b6021ef9e6892dcf14dc5dd269afaada763fedc13b29-ihxenu_fw658.jpeg')6 plt.imshow (IMG)7 plt.show ()8 #Convert to Arrays9IMG =Np.asarray (IMG)Ten Print('image matrix Size:', Img.shape) One A #capture the image above and discard the following 20 lines -Bottom = 50 -IMG = img[:-bottom,:] the - #Number of Ticks -XScale = 5 -Yscale = 6 + -Fig = Plt.figure ('Image') + plt.imshow (IMG) A #generate coordinates according to seniors ' requirements atPlt.xticks ([img.shape[1]/xscale*w forWinchRange (xscale+1)], ['%.1f'% (87.3-(87.3-82.2)/xscale*w) forWinchRange (xscale+1)]) -Plt.yticks ([(Img.shape[0]-bottom)/yscale*w forWinchRange (yscale+1)], ['%.1f'% ( -3.5-( -3.5-(-(Img.shape[1]-bottom)/img.shape[1]* ( -3.5-1.5) -3.5))/yscale*w) forWinchRange (yscale+1)]) -Plt.xlabel ("Galactic Longitude") -Plt.ylabel ("Galactic Latitude") - plt.show () -Fig.savefig ('result.eps', format='EPS') inFig.savefig ('Result.png', format='PNG')
/home/hellcat/anaconda2/envs/python3_6/bin/python/home/hellcat/pycharmprojects/data_analysis/help brother fix map/handle _piecture.py Image Matrix Size: (924, 658, 3) Process finished with exit code 0
By the way:
Plt.xticks ([Img.shape[1]/xscale*w for W in Range (xscale+1)], ['%.1f'% (87.3-(87.3-82.2)/xscale*w ) for W in range (xscale+1)])
This sentence is also super easy to use, although it is Matplotlib.pyplot package, but Numpy.asarray () is not PiL bag AH ~ ~
"Python" PIL image processing _ Matrix transformation