---
# System prepended metadata

title: 4/13

---

4/13
===
conda install -c conda-forge imutils
```
import matplotlib.pyplot as plt
import cv2

img=cv2.imread('car.jpg',1)
img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
laplaction=cv2.Laplacian(img,cv2.CV_64F)
sobelx=cv2.Sobel(img,cv2.CV_64F,1,0,ksize=5)
sobely=cv2.Sobel(img,cv2.CV_64F,0,1,ksize=5)
canny=cv2.Canny(img,100,1000)


'''
cv2.imshow('L',laplaction)
cv2.imshow('sx',sobelx)
cv2.imshow('sy',sobely)
cv2.imshow('canny',canny)

cv2.waitKey()
cv2.destroyAllWindows()
'''
plt.subplot(2,2,1) #2欄2列圖
plt.imshow(img,cmap='gray')
plt.title('laplacian')
plt.xticks([])
plt.yticks([])

plt.subplot(2,2,2) #2欄2列圖
plt.imshow(sobelx,cmap='gray')
plt.title('sobelx')
plt.xticks([])
plt.yticks([])

plt.subplot(2,2,3) #2欄2列圖
plt.imshow(sobely,cmap='gray')
plt.title('sobely')
plt.xticks([])
plt.yticks([])

plt.subplot(2,2,4) #2欄2列圖
plt.imshow(canny,cmap='gray')
plt.title('canny')
plt.xticks([])
plt.yticks([])

```

```
import cv2
import numpy as np
import imutils
image = cv2.imread('002.jpg')
image = imutils.resize(image,width=500)
cv2.imshow('Original',image)
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
cv2.imshow('Gray',gray)
gray = cv2.bilateralFilter(gray,11,17,17)
cv2.imshow('Bilater',gray)

canny = cv2.Canny(gray,170,200)
cv2.imshow('canny',canny)
(new,cnts,_) = cv2.findContours(canny.copy(),cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)

cnts = sorted(cnts,key=cv2.contourArea,reverse=True)[:30]
NumberPlateCnt = None
count = 0
for c in cnts:
    peri = cv2.arcLength(c,True)
    approx = cv2.approxPolyDP(c,0.02*peri,True)
    if (len(approx) == 4):
        NumberPlateCnt = approx
        break
    
    
cv2.drawContours(image,[NumberPlateCnt],-1,(0,0,255),3)    
cv2.imshow('Final Image',image)
cv2.waitKey()
cv2.destroyAllWindows()
```