Python calls the Matplotlib code to draw the point map of the distribution point matplotlib Introduction code screenshot
1. The purpose of drawing a point chart
Our lab is doing a face recognition project, in which there are some false-check pictures after the face detection, but there are a lot of things that don't match. It is obvious from the size of the picture, you can filter out a part. The boss gave me the job, that is, by drawing a picture of the distribution map, to find a reasonable threshold value. width,height
2.Matlablib Introduction
Matplotlib is a Python graphics frame
Here is an example of the official website
matplotlib Example
3. The code is as follows
Import Matplotlib.pyplot as PLT from numpy.random import rand import numpy import os import cv2 #setting plt Plt.xlim (xma x=500,xmin=0) Plt.ylim (ymax=500,ymin=0) plt.xlabel ("height") plt.ylabel ("width") path_1 = R ' D:\zhangjichao\view\path _1 ' x = [] y = [] files = Os.listdir (path_1) for f in files:img = Cv2.imread (path_1 + ' \ \ + f) x.append (img.sh
Ape[0] Y.append (img.shape[1]) plt.plot (x,y, ' ro ', color= ' red ', label= ' path_1 ') path_2 = R ' D:\zhangjichao\view\path_2 ' x = [] y = [] files = Os.listdir (path_2) for f in files:img = Cv2.imread (path_2 + ' \ \ + f) x.append (img.shape[0 ] Y.append (img.shape[1]) plt.plot (x,y, ' ro ', color= ' red ', label= ' path_2 ') Path_3 = R ' D:\zhangjichao\view\path_3 ' x =
[] y = [] files = Os.listdir (Path_3) for f in files:img = Cv2.imread (path_3 + ' \ \ + f) x.append (img.shape[0)) Y.append (Img.shape[1]) plt.plot (x,y, ' ro ', color= ' red ', label= ' path_3 ') Path_4 = R ' D:\zhangjichao\view\path_4 ' x = [] y = [] files = Os.listdir (path_4For f in files:img = Cv2.imread (path_4 + ' \ \ + f) x.append (Img.shape[0]) y.append (img.shape[1]) Plt.plot (x , y, ' ro ', color= ' red ', label= ' path_4 ') yujing = R ' D:\zhangjichao\view\xujing ' x = [] y = [] files = Os.listdir (yujing) for F in files:img = Cv2.imread (yujing + ' \ ' + f) x.append (Img.shape[0]) y.append (img.shape[1]) plt.plot (x,y, ' ro ', color= ' green ', label= ' yujing ') #图例 plt.legend (loc= ' Upper Center ', shadow=true, fontsize= ' X-large ') Plt.grid (True) #显 Plt.show ()
4. Display Results