實用小工具---顯示影象點座標和點的rgb值
阿新 • • 發佈:2019-02-02
第一步:在python27資料夾下建立一個mytool資料夾,然後建立showpicture.py
#coding:utf-8 ''' python showpicture.py --image *.png ''' from PIL import Image from pylab import * from PCV.tools import imtools import argparse import cv2 ap = argparse.ArgumentParser() ap.add_argument("-i","--image",required=True,help="Path to the image") args = vars(ap.parse_args()) from matplotlib.font_manager import FontProperties font = FontProperties(fname=r"C:/Windows/Fonts/msyh.ttc", size=14) #im = array(Image.open('C:/pytm/pic/ceshi.jpg').convert('L')) im1 = array(Image.open(args["image"])) subplot() axis('off') title(u'Picture', fontproperties=font) imshow(im1) show()
第二步,在cmd中執行:
(假設在python27/mytool下有一個trex.png影象)
python showpicture.py --image trex.png
第二版:
直接在eclipse上執行的:
#coding:utf-8 ''''' python showpicture.py --image *.png ''' from PIL import Image from pylab import * from matplotlib.font_manager import FontProperties font = FontProperties(fname=r"C:/Windows/Fonts/msyh.ttc", size=14) im1 = array(Image.open('d:/0000/5/5.jpg')) subplot() gray() axis('off') title(u'Picture', fontproperties=font) imshow(im1) show()