![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图像处理
实现图像处理的一些例程
一名CV界的小学生
这个作者很懒,什么都没留下…
展开
-
Skimage:img_as_float
参考:skimage_Scikit image_参考手册_非常教程Python skimage.img_as_float方法代码示例 - 纯净天空 相应的例程代码原创 2022-01-04 15:16:26 · 3700 阅读 · 0 评论 -
离线数据增强
def imgAug(imgDir,dstImg): params = [0.5, 0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4, 1.5] gaussParams=[3,5] imgNames=[img for img in os.listdir(imgDir)] for name in imgNames: img = Image.open(os.path.join(imgDir,name)) brightE.原创 2021-12-28 17:37:22 · 1603 阅读 · 0 评论 -
离线数据增强 PIL
使用一幅图像可得到600到900张图像def imgAug(imgDir,name,dstImg): params = [0.5, 0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4, 1.5] img = Image.open(os.path.join(imgDir,name)) brightEnhance = ImageEnhance.Brightness(img) contrastEnhance = ImageEnhance.Contr.原创 2021-12-24 15:13:33 · 1545 阅读 · 0 评论 -
借助PIL库实现图像旋转
def imgRotate(imgDir): img=Image.open(imgDir) img90=img.transpose(Image.ROTATE_90) img180=img.transpose(Image.ROTATE_180) img270=img.transpose(Image.ROTATE_270) img180.save('img1.jpg') plt.figure(figsize=(10,10)) plt.suptitle('.原创 2021-12-10 17:54:38 · 2978 阅读 · 0 评论 -
opencv:SIFT 校正
def SIFT(inpic,template): sift = cv2.xfeatures2d.SIFT_create() grayPic=cv2.cvtColor(inpic,cv2.COLOR_BGR2GRAY) img1 = grayPic[100:1000,:] img2 = template[100:1000,:] kp1, des1 = sift.detectAndCompute(img1,None) kp2, des2 = sift.dete.原创 2021-12-07 15:19:54 · 460 阅读 · 1 评论 -
opencv:图像直方图均衡化
def calcGrayHist(image): rows,cols=image.shape grayHist=np.zeros([256],np.uint64) for r in range(rows): for c in range(cols): grayHist[image[r][c]]+=1 return grayHistdef equalHist(imgDir): imgGray=cv2.imread(img.原创 2021-12-02 22:59:48 · 2200 阅读 · 0 评论 -
opencv:gamma变换
gamma变换是对图像像素值归一化到[0,1]后,对像素值进行幂运算。def gammaTransform(imgDir): imgGray=cv2.imread(imgDir,cv2.IMREAD_GRAYSCALE) cv2.imshow("raw",imgGray) imgGrayNorm=imgGray/255 gamma=2 dst=np.power(imgGrayNorm,gamma) cv2.imshow("test",dst)原创 2021-12-02 21:43:14 · 1905 阅读 · 0 评论 -
opencv:图像归一化
def histNorm(imgDir): imgGray=cv2.imread(imgDir,cv2.IMREAD_GRAYSCALE) cv2.imshow("raw",imgGray) maxPixelsValue=np.max(imgGray) minPixelsValue=np.min(imgGray) outMin, outMax=0,255 a=float(outMax-outMin)/(maxPixelsValue-minPixelsV.原创 2021-12-02 21:32:37 · 3666 阅读 · 0 评论 -
opencv:线性变换
def linearTrans(imgDir): imgGray=cv2.imread(imgDir,cv2.IMREAD_GRAYSCALE) cv2.imshow("raw",imgGray) a=0.2 dst=float(2)*imgGray dst[dst>25]=255 # 将数组dst中大于25的值均设置为255 dst=np.round(dst) dst=dst.astype(np.uint8) #成员函数astype的作用改.原创 2021-12-02 21:39:51 · 2715 阅读 · 0 评论 -
opencv:计算直方图
def calcGrayHist(image): rows,cols=image.shape grayHist=np.zeros([256],np.uint64) for r in range(rows): for c in range(cols): grayHist[image[r][c]]+=1 return grayHistdef showHist(imgDir): img=cv2.imread(imgDir).原创 2021-12-02 20:55:22 · 186 阅读 · 0 评论 -
opencv:仿射变换
opencv API :cv2.warpAffinedef warpAffineTest(imgDir): img=cv2.imread(imgDir,cv2.IMREAD_GRAYSCALE) h,w=img.shape[:2] A1=np.array([[0.5,0,0],[0,0.5,0]],np.float32)# 缩小2倍 d1=cv2.warpAffine(img,A1,(h,w),borderValue=125) cv2.imshow(".原创 2021-11-30 22:02:11 · 907 阅读 · 0 评论 -
PYTHON:将图像缩放至固定尺寸,并生成相应的路径列表
import cv2 as cvimport osdef resize_img(src_dir, dst_dir, imgList416, img_size): ''' :param src_dir: train.txt dir :param dst_dir: 416*416 img save dir :param imgList416: 416*416 img list txt file :param img_size: img scale :re.原创 2021-11-05 10:11:18 · 503 阅读 · 0 评论 -
图像处理:随机擦除某区域
import cv2import mathimport randomdef randomErasing(imgDir, sl=0.02, sh=0.4, r1=0.3, mean=(0.4914, 0.4822, 0.4465)): img = cv2.imread(imgDir) area = img.shape[0] * img.shape[1] target_area = random.uniform(sl, sh) * area aspect_ratio.原创 2021-08-30 17:20:22 · 1377 阅读 · 2 评论 -
python: 视频中选择感兴趣区域
介绍:LoadVideo的类是在阅读fairMOT源码时看到的一种视频读取方式,感觉很精巧。做一个代码的记录。同时也是对这种视频读取方式的备忘。该处理方式也是python语法的一种进阶。import cv2import numpy as npimport sysclass LoadVideo: def __init__(self, path, img_size=(1088, 608)): self.cap = cv2.VideoCapture(pa...原创 2021-08-06 11:31:46 · 492 阅读 · 0 评论 -
yolo:letterbox(padding)
opencv API:cv2.copyMakeBorder示例代码:import cv2def letterbox(img,height=608,width=1088, color=(127.5,127.5,127.5)): shape=img.shape[:2] # shape=[height,width] ratio=min(float(height)/shape[0],float(width)/shape[1]) newShap原创 2021-07-16 10:11:26 · 743 阅读 · 2 评论 -
opencv 通过计算SIFT描述符与三通道直方图计算比较图像相似度
#include <iostream>#include "opencv2/opencv.hpp"#include "opencv2/xfeatures2d.hpp"int main(){ std::string img00Dir="/home/wang/images/person_02.png"; std::string img01Dir="/home/wang/images/person_03.png"; cv::Mat img01=cv::imread(.原创 2021-05-20 11:45:28 · 538 阅读 · 1 评论 -
opencv API getTickCount
double t = (double)getTickCount(); // do something ...t = ((double)getTickCount() - t)/getTickFrequency();double t = (double)getTickCount();//The function returns the number of ticks per second. That is, the following code computes the execution ti.原创 2021-03-23 14:22:52 · 130 阅读 · 0 评论 -
opencv 计算两幅图像相似度(欧氏距离,余弦距离)
功能:利用HOG特征比较两幅图像的相似度opencv PAI:CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1, int _histogramNormType=HOGDescriptor::L2原创 2021-05-14 16:16:18 · 7570 阅读 · 2 评论 -
opencv 视频中选择感兴趣区域(ROI)
opencv 使用到的主要接口:setMouseCallback()尝试加入C++对象的思想对主要方法进行封装。代码如下:MyVideoCapture.h 文件如下//// Created by wang on 2021/5/8.//#ifndef MOUSESELECT_EXAMPLE_00_MYVIDEOCAPTURE_H#define MOUSESELECT_EXAMPLE_00_MYVIDEOCAPTURE_H#include "MouseSelect.h"c原创 2021-05-10 14:54:11 · 726 阅读 · 0 评论 -
图像处理:均值滤波
借助于opencv的数据类型Mat简单实现均值滤波,该代码并未考虑边缘影响#include <iostream>#include "vector"#include "algorithm"#include "opencv2/highgui.hpp"#include "opencv2/core/core.hpp"#include "opencv2/opencv.hpp"int mymean(int n1,int n2,int n3,int n4,int n5,int n6,int原创 2021-04-18 15:03:40 · 336 阅读 · 0 评论 -
图像处理:中值滤波
借助于opencv的数据结构Mat 实现图像处理中值滤波算法代码中刻意添加了椒盐噪声,凸显中值滤波的效果。#include <iostream>#include "vector"#include "algorithm"#include "opencv2/highgui.hpp"#include "opencv2/core/core.hpp"#include "opencv2/opencv.hpp"int mymedian(int n1,int n2,int n3,int n原创 2021-04-18 14:04:41 · 318 阅读 · 0 评论 -
图像处理:图像金字塔
#include <vector>#include <string>#include <iostream>#include <opencv2/opencv.hpp>int patch_size=32;const float scale_stride = sqrt(2);int scale_num = 8;void InitPry(const cv::Mat& frame, std::vector<float>& .原创 2021-03-31 22:48:45 · 134 阅读 · 0 评论 -
opencv 追踪例程 展示
#include <opencv2/opencv.hpp>#include <opencv2/tracking.hpp>#include <opencv2/core/ocl.hpp>using namespace cv;using namespace std;// Convert to string#define SSTR( x ) static_cast< std::ostringstream & >( \( std::ostri.原创 2021-02-25 16:51:24 · 363 阅读 · 0 评论 -
选择ROI区域
参考:https://www.cnblogs.com/dwdxdy/p/3244117.html 以类的形式封装鼠标交互方式,利用setMouseCallback() 接口给固定的窗口设置鼠标回调函数。原创 2021-02-23 17:00:39 · 151 阅读 · 0 评论 -
kalman 追踪实例 鼠标追踪二
#include "opencv2/video/tracking.hpp"#include "opencv2/highgui/highgui.hpp"#include <stdio.h>using namespace cv;using namespace std;const int winHeight=600;const int winWidth=800;Point mousePosition= Point(winWidth>>1,winHeight>&g.原创 2021-02-20 15:29:18 · 114 阅读 · 0 评论 -
kalman追踪实例 鼠标跟踪
#include "opencv2/video/tracking.hpp"#include "opencv2/highgui/highgui.hpp"#include <stdio.h>using namespace cv;using namespace std;const int winHeight=600;const int winWidth=800;Point mousePosition= Point(winWidth>>1,winHeight>&g.原创 2021-02-19 11:14:14 · 248 阅读 · 0 评论 -
OpenCV 图像拼接与图像融合
https://www.cnblogs.com/skyfsm/p/7411961.html转载 2019-02-27 16:33:13 · 669 阅读 · 0 评论