연구 노트 (23) : 컴퓨터 비전 (첫 번째 분기를) 이해하고 학교 - 이미지 전투 운동을 변환

바로 학습 : https://edu.csdn.net/course/play/26281/327083?utm_source=blogtoedu

1. 거리 변환

2.Log 극성 변환

 3. 계산 히스토그램

4. 히스토그램 등화

 

 표준 허프 변환

6. 누적 확률은 허프 변환 : 결과는 변환 종종 더 나은 표준 호우보다.

이미지 크기 조정

cv.resize (화상 (폭, 높이))

이미지 반전 (flipCode 값 : 0, x 축 방향 대칭> 0- Y 축 <는 X 0- 따라, 동시에 반전 Y 축 대칭) 

cv.flip (화상 flipCode)

import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np

filename= "d:/lena.jpg"
img=cv.imread(filename)

#图像改变大小
w,h = img.shape[0:2]
resized = cv.resize(img, (int(w/2), int(h/2)))
flipped_0 = cv.flip(resized, 0)
flipped_1 = cv.flip(resized, 1)

cv.imshow("resized", resized)
cv.imshow("flipped 0", flipped_0)
cv.imshow("flipped 1", flipped_1)
cv.waitKey()
cv.destroyAllWindows()

#实现图像的距离变换
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
#二值化
ret, thr = cv.threshold(gray, 100, 255, cv.THRESH_OTSU)
dist = cv.distanceTransform(thr, cv.DIST_L2, cv.DIST_MASK_3)
dist_norm = cv.convertScaleAbs(dist)
cv.imshow("gray", gray)
cv.imshow("thr", thr)
cv.imshow("dist", dist_norm)
cv.waitKey()
cv.destroyAllWindows()

#实现Log-polar变换
center = (w/2, h/2)
maxRadius = 0.7*min(center)
M = w/cv.log(maxRadius)
print(maxRadius, M[0])
log_polar = cv.logPolar(img, center, M[0]*0.8, cv.INTER_LINEAR + cv.WARP_FILL_OUTLIERS)
cv.imshow("logpolar", log_polar)

#显示灰度直方图
plt.hist(gray.ravel(), 256, [0,256])
plt.show()

#均衡化
equa = cv.equalizeHist(gray)
cv.imshow("equalized image", equa)
cv.waitKey()
cv.destroyAllWindows()

#Hough变换
edge = cv.Canny(thr, 50, 150)
disp_edge = cv.cvtColor(edge, cv.COLOR_GRAY2BGR)
lines = cv.HoughLinesP(edge, 1, 1*np.pi/180, 10)
for line in lines:
    for x1, y1, x2, y2 in line:
        #画出直线
        cv.line(disp_edge, (x1,y1), (x2,y2), (0, 255, 0), 1)
    pass
print("Line count: ", len(lines))
cv.imshow("edge", edge)
cv.imshow("draw_line", disp_edge)
cv.waitKey()
cv.destroyAllWindows()

 렌더링 :

 

 

 

게시 65 개 원래 기사 · 원의 찬양 (34) · 전망 260 000 +

추천

출처blog.csdn.net/huanggang982/article/details/104830025