二值化方法介绍
https://www.cnblogs.com/Imageshop/p/3307308.html
https://github.com/jingweizhanghuai/image
图像增强方法介绍
https://www.cnblogs.com/molakejin/p/5766127.html
https://www.cnblogs.com/sleepwalker/p/3676600.html
图像暗角去除
https://www.cnblogs.com/Imageshop/p/6166394.html
边缘提取方法介绍
https://blog.csdn.net/weixin_38907330/article/details/80874031
直线检测方法介绍
https://blog.csdn.net/weixin_42647783/article/details/81200534
https://blog.csdn.net/leonardohaig/article/details/87907462
图像矩阵运算方法介绍
rotate
https://www.cnblogs.com/meteoric_cry/p/7987548.html
对极几何及空间中相机标定
https://blog.csdn.net/qq_36622009/article/details/104919996
https://blog.csdn.net/Ketal_N/article/details/83744626
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 28 14:20:43 2014
@author: duan
"""
import cv2
import numpy as np
from matplotlib import pyplot as plt
img1 = cv2.imread('myleft.jpg',0) #queryimage # left image
img2 = cv2.imread('myright.jpg',0) #trainimage # right image
sift = cv2.SIFT()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
# FLANN parameters
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=50)
flann = cv2.FlannBasedMatcher(index_params,search_params)
matches = flann.knnMatch(des1,des2,k=2)
good = []
pts1 = []
pts2 = []
# ratio test as per Lowe's paper
for i,(m,n) in enumerate(matches):
if m.distance < 0.8*n.distance:
good.append(m)
pts2.append(kp2[m.trainIdx].pt)
pts1.append(kp1[m.queryIdx].pt)
pts1 = np.int32(pts1)
pts2 = np.int32(pts2)
F, mask = cv2.findFundamentalMat(pts1,pts2,cv2.FM_LMEDS)
# We select only inlier points
pts1 = pts1[mask.ravel()==1]
pts2 = pts2[mask.ravel()==1]
def drawlines(img1,img2,lines,pts1,pts2):
''' img1 - image on which we draw the epilines for the points in img2
lines - corresponding epilines '''
r,c = img1.shape
img1 = cv2.cvtColor(img1,cv2.COLOR_GRAY2BGR)
img2 = cv2.cvtColor(img2,cv2.COLOR_GRAY2BGR)
for r,pt1,pt2 in zip(lines,pts1,pts2):
color = tuple(np.random.randint(0,255,3).tolist())
x0,y0 = map(int, [0, -r[2]/r[1] ])
x1,y1 = map(int, [c, -(r[2]+r[0]*c)/r[1] ])
img1 = cv2.line(img1, (x0,y0), (x1,y1), color,1)
img1 = cv2.circle(img1,tuple(pt1),5,color,-1)
img2 = cv2.circle(img2,tuple(pt2),5,color,-1)
return img1,img2
# Find epilines corresponding to points in right image (second image) and
# drawing its lines on left image
lines1 = cv2.computeCorrespondEpilines(pts2.reshape(-1,1,2), 2,F)
lines1 = lines1.reshape(-1,3)
img5,img6 = drawlines(img1,img2,lines1,pts1,pts2)
# Find epilines corresponding to points in left image (first image) and
# drawing its lines on right image
lines2 = cv2.computeCorrespondEpilines(pts1.reshape(-1,1,2), 1,F)
lines2 = lines2.reshape(-1,3)
img3,img4 = drawlines(img2,img1,lines2,pts2,pts1)
plt.subplot(121),plt.imshow(img5)
plt.subplot(122),plt.imshow(img3)
plt.show()
TPS(薄板样条) 2D 插值
https://blog.csdn.net/swimmingfish2004/article/details/7666087
https://www.cnblogs.com/xiaotie/archive/2009/10/15/1583730.html
车牌生成:
https://github.com/szad670401/end-to-end-for-chinese-plate-recognition/blob/master/PlateCommon.py
grapcut ,floodfill,分水岭算法watershed
https://www.cnblogs.com/little-monkey/p/7598529.html
https://blog.csdn.net/qq_33414271/article/details/78664123
https://www.cnblogs.com/zyly/p/9392881.html
图像去模糊
https://arxiv.org/pdf/1803.03363.pdf
图像合成,动漫效果色彩,seamlessclone
https://www.jianshu.com/p/c0759e322de7
https://www.jianshu.com/p/49adfbe4b804
图像调试工具imagewatch
https://blog.csdn.net/swartz_lubel/article/details/70314179
https://blog.csdn.net/youngpan1101/article/details/72236744
颜色直方图
https://www.cnblogs.com/panchuangai/p/12567891.html
https://blog.csdn.net/GiffordY/article/details/92764602
方向投影
https://blog.csdn.net/qq_27923041/article/details/82703685
CLAHE 有限对比适应性直方图均衡化
https://www.jianshu.com/p/5e8392ec1940
OCR特征
https://blog.csdn.net/yang843061497/article/details/38553765/
小波变换
https://www.cnblogs.com/jfdwd/p/9249850.html
去噪
https://blog.csdn.net/qq_30815237/article/details/86737690
#include"opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
//equalize hist
bool equalize_histFun(Mat &src, Mat &dst)
{
if (src.empty())
{
cout << "img not exist!" << endl;
return false;
}
if (src.channels == 3)
{
Mat imageRGB[3];
split(src, imageRGB);
equalizeHist(imageRGB[0], imageRGB[0]);
equalizeHist(imageRGB[1], imageRGB[1]);
equalizeHist(imageRGB[2], imageRGB[2]);
merge(imageRGB, 3, dst);
}
else if (src.channels == 1)
{
equalizeHist(src, dst);
}
return true;
}
//laplace sharp
bool laplace_sharp(Mat &src, Mat &dst)
{
if (src.empty())
{
cout << "img not exist!" << endl;
return false;
}
Mat kernel = (Mat_<float>(3, 3) << 0, -1, 0, 0, 5, 0, 0, -1, 0);
filter2D(src, dst, src.depth,kernel);
return true;
}
bool Log_improce_darkimg(Mat &src, Mat &dst)
{
if (src.empty())
{
cout << "img not exist!" << endl;
return false;
}
if (src.channels == 3)
{
Mat imagelog(src.size(), CV_32FC3);
for (int i = 0; i < src.rows; i++)
{
for (int j = 0; j < src.cols; j++)
{
imagelog.at<Vec3f>(i, j)[0] = log(1 + src.at<Vec3b>(i, j)[0]);
imagelog.at<Vec3f>(i, j)[1] = log(1 + src.at<Vec3b>(i, j)[1]);
imagelog.at<Vec3f>(i, j)[2] = log(1 + src.at<Vec3b>(i, j)[2]);
}
}
//normalize to 0 ~ 255
normalize(imagelog, imagelog, 0, 255, CV_MINMAX);
//conver to 8bit image data
convertScaleAbs(imagelog, dst);
}
else if (src.channels == 1)
{
Mat imagelog(src.size(), CV_32FC1);
for (int i = 0; i < src.rows; i++)
{
for (int j = 0; j < src.cols; j++)
{
imagelog.at<Vec3f>(i, j)[0] = log(1 + src.at<Vec3b>(i, j)[0]);
}
}
//normalize to 0 ~ 255
normalize(imagelog, imagelog, 0, 255, CV_MINMAX);
//conver to 8bit image data
convertScaleAbs(imagelog, dst);
}
return true;
}
//Gamma ,if fGamma < 1 will spread dark ; big 1 will spread bright
void MyGammaCorrection(Mat& src, Mat& dst, float fGamma = 3)
{
CV_Assert(src.data);
// accept only char type matrices
CV_Assert(src.depth() != sizeof(uchar));
// build look up table
unsigned char lut[256];
for (int i = 0; i < 256; i++)
{
lut[i] = saturate_cast<uchar>(pow((float)(i / 255.0), fGamma) * 255.0f);
}
dst = src.clone();
const int channels = dst.channels();
switch (channels)
{
case 1:
{
MatIterator_<uchar> it, end;
for (it = dst.begin<uchar>(), end = dst.end<uchar>(); it != end; it++)
//*it = pow((float)(((*it))/255.0), fGamma) * 255.0;
*it = lut[(*it)];
break;
}
case 3:
{
MatIterator_<Vec3b> it, end;
for (it = dst.begin<Vec3b>(), end = dst.end<Vec3b>(); it != end; it++)
{
//(*it)[0] = pow((float)(((*it)[0])/255.0), fGamma) * 255.0;
//(*it)[1] = pow((float)(((*it)[1])/255.0), fGamma) * 255.0;
//(*it)[2] = pow((float)(((*it)[2])/255.0), fGamma) * 255.0;
(*it)[0] = lut[((*it)[0])];
(*it)[1] = lut[((*it)[1])];
(*it)[2] = lut[((*it)[2])];
}
break;
}
}
}
// float k[9] = { -1.0, -1.0, -1.0,
// -1.0, 9.0, -1.0,
// -1.0, -1.0, -1.0 }; //核 high pass
// float k[9] = { 0.1, 0.1, 0.1,
// 0.1, 0.2, 0.1,
// 0.1, 0.1, 0.1 }; //核 low pass
// Mat km = Mat( 3, 3, CV_32FC1, k ); //构造单通道浮点矩阵
// filter2D (bi,bi,bi.depth(),km);
//
/*************************************************
Function: 通过直方图变换进行图像增强,将图像灰度的域值拉伸到0-255
src1: 单通道灰度图像
dst1: 同样大小的单通道灰度图像
*************************************************/
int ImageStretchByHistogram(IplImage *src1, IplImage *dst1)
{
assert(src1->width == dst1->width);
double p[256], p1[256], num[256];
memset(p, 0, sizeof(p));
memset(p1, 0, sizeof(p1));
memset(num, 0, sizeof(num));
int height = src1->height;
int width = src1->width;
long wMulh = height * width;
//statistics
for (int x = 0; x<src1->width; x++)
{
for (int y = 0; y<src1->height; y++){
uchar v = ((uchar*)(src1->imageData + src1->widthStep*y))[x];
num[v]++;
}
}
//calculate probability
for (int i = 0; i<256; i++)
{
p[i] = num[i] / wMulh;
}
//p1[i]=sum(p[j]); j<=i;
for (int i = 0; i<256; i++)
{
for (int k = 0; k <= i; k++)
p1[i] += p[k];
}
// histogram transformation
for (int x = 0; x<src1->width; x++)
{
for (int y = 0; y<src1->height; y++){
uchar v = ((uchar*)(src1->imageData + src1->widthStep*y))[x];
((uchar*)(dst1->imageData + dst1->widthStep*y))[x] = p1[v] * 255 + 0.5;
}
}
return 0;
}