OpenCv
1, Jpg压缩
#include <opencv2\opencv.hpp> #include<iostream> #include <stdio.h> using namespace cv; int main(int argc, char **argv) { int p[3]; IplImage *img = cvLoadImage("test.jpg"); p[0] = CV_IMWRITE_JPEG_QUALITY; p[1] = 100; p[2] = 0; cvSaveImage("out2.jpg", img, p); return 0; }
2,图像腐蚀与膨胀
int inflateStaticMap(const std::string &map_file, int inflate_factor) { if (map_file.empty() || inflate_factor == 0) { return -1; } Mat src, erosion_dst; src = imread(map_file, IMREAD_COLOR ); if ( src.empty() ) { return -1; } //![kernel] Mat element = getStructuringElement(MORPH_RECT, Size( inflate_factor + 1, inflate_factor + 1 ), Point( -1, -1 ) ); /// Apply the erosion operation erode( src, erosion_dst, element); imwrite(map_file + ".inflate", erosion_dst); return 0; } int main (int argc, char **argv) { inflateStaticMap("test.jpg", 0); }