from PIL import Image #Image Library from pylab import * #Matplotlib #load image array im = array(Image.open('images/empire.jpg')) # display image imshow(im) # create some points x = [100,100,400,400] y = [200,500,200,500] # plot points in red plot(x,y, 'r*') # plot connecting points plot(x[:2],y[:2], 'm') # remove axis axis('off') # add title title('Plotting: "Empire.jpg"') show() # Contour and Histogram Example -------------------------- #load image array in B/W im_bw = array(Image.open('images/empire.jpg').convert('L')) # create figure figure() #remove colors gray() # show contour contour(im_bw, origin='image') # axis axis('equal') axis('off') show() # histogram of pixel distribution figure() # flatten converts the image to be # 1 dimensional hist(im_bw.flatten(), 128) #render show()