【c++|opencv】二、灰度变换和空间滤波---3.均值滤波
1. 均值滤波12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455#include <iostream>#include <opencv2/opencv.hpp>#include"Salt.h"using namespace cv;using namespace std;// 定义盒式滤波器void myfilter(int filter_size,Mat& img_input,Mat& img_output);int main(){ Mat img,img_gray,img_output,img_output2; img = imread("/home/v/home.png"); if (img.empty()){ cout<<"can not load image"< ...
【c++|opencv】二、灰度变换和空间滤波---2.直方图
1. 图像直方图1234567891011121314151617181920212223242526272829303132333435363738394041#include <iostream>#include <opencv2/opencv.hpp>using namespace cv;using namespace std;int main(){ Mat img, img_gray,hist; img = imread("/home/v/home.png"); if (img.empty()){ cout << "Could not open or find the image" << endl; return -1; } cvtColor(img, img_gray, COLOR_BGR2GRAY); imshow("img gray",img_gray); // 获取 ...
【c++|opencv】二、灰度变换和空间滤波---1.灰度变换
1. 灰度变换1234567891011121314151617181920212223242526272829303132#include <iostream>#include <opencv2/opencv.hpp>using namespace std;using namespace cv;int main() { Mat img,out_img,img_gray; img = imread("/home/v/home.png"); if (img.empty()){ cout << "Could not open or find the image" << endl; return -1; } cvtColor(img, img_gray, COLOR_BGR2GRAY); imshow("img gray",img_gray); out_img = img_gr ...
【c++|opencv】一、基础操作---4.访问图像像素
1. 访问图像像素1.1 访问某像素123456//灰度图像:image.at<uchar>(j, i) //j为行数,i为列数//BGR彩色图像image.at<Vec3b>(j, i)[0] //B分量image.at<Vec3b>(j, i)[1] //G分量image.at<Vec3b>(j, i)[2] //R分量
1.2 遍历像素以添加噪声为例
1.2.1 准备创建添加噪声函数
Salt.h
123456789#pragma once#include <iostream>#include <opencv2/opencv.hpp>#include <random>using namespace cv;using namespace std;void Salt(Mat img,int n); // n加入噪声点数
Salt.cpp
1234567891011121314151617181920212223#include "Salt.h"void Salt(Mat img, ...
【c++|opencv】一、基础操作----2.图像信息获取
1. 图像信息获取123456789101112131415161718192021222324// 获取图像信息#include <iostream>#include <opencv2/opencv.hpp>using namespace cv;using namespace std;int main(){ Mat img = imread("/home/v/home.png"); if(img.empty()){ cout<<"Error: Could not load image."<<endl; return -1; } imshow("img",img); cout<<"img row: "<<img.rows<<endl; cout<<"img col: "<<img.cols ...
【c++|opencv】一、基础操作----1.图像读取
1. 图像读取、显示、保存// 读取、显示、保存图像
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(){
Mat img; // 创建空图像
img = imread("/home/v/home.png") ;
if(img.empty()){
cout << "读取图片失败" << endl;
return -1;
}
namedWindow("home"); // 无这行窗口大小不能改变
imshow("home", img);
imwrite("a.png",img);
waitKey(0);
return 0;
}```
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new "My New Post"
More info: Writing
Run server1$ hexo server
More info: Server
Generate static files1$ hexo generate
More info: Generating
Deploy to remote sites1$ hexo deploy
More info: Deployment
【PCL】7. 滤波
1. 直通滤波代码:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include <iostream>#include <pcl/point_types.h>#include <pcl/filters/passthrough.h>int main(int argc, char** argv){ pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>); // 生成数据 cloud->width = 5; cloud->height = 1; clo ...
【PCL】6. 输入输出
1. 读取文件1234567891011121314151617181920212223242526#include <iostream>#include <pcl/io/pcd_io.h>#include <pcl/point_types.h>int main(int argc, char** argv){ pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); // 打开点文件 if (pcl::io::loadPCDFile<pcl::PointXYZ>("../test.pcd", *cloud) == -1){ PCL_ERROR("Couldn't read file point_cloud.pcd \n"); return (-1); } // 默认就是二进制块读取 ...
【PCL】5. 深度图
1. 从点云创建深度图#include <pcl/range_image/range_image.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/visualization/range_image_visualizer.h>
int main(int argc, char** argv){
pcl::PointCloud<pcl::PointXYZ>::Ptr PointCloudPtr(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ> &PointCloud = *PointCloudPtr;
pcl::io::loadPCDFile("../bunny.pcd", PointCloud); // 加载数据
fl ...