#include"opencv_test.h" opencv_t::opencv_t() { } opencv_t::~opencv_t() { } opencv_t* opencv_t::create_new() { opencv_t* temp = nullptr; temp = new opencv_t(); return temp; } void opencv_t::visit_xiangsu(Mat& temp) { int w = temp.cols; int h = temp.rows; int dims = temp.channels(); for (int row = 0; row < h; row++) { for (int col = 0; col < w; col++) { if (dims == 1) { int pv = temp.at(row, col); temp.at(row, col) = 255 - pv; } else if (dims == 3) { Vec3b pv = temp.at(row, col); temp.at(row, col)[0] = 255 - pv[0]; temp.at(row, col)[1] = 255 - pv[1]; temp.at(row, col)[2] = 255 - pv[2]; } } } } void opencv_t::visit_xiangsu(Mat& temp, int a) { int w = temp.cols; int h = temp.rows; int dims = temp.channels(); for (int row = 0; row < h; row++) { uchar* curr = temp.ptr(row); for (int col = 0; col < w; col++) { if (dims == 1) { int pv = *curr; *curr++ = 255 - pv; } else if (dims == 3) { *curr++ = 255 - *curr; *curr++ = 255 - *curr; *curr++ = 255 - *curr; } } } } Mat opencv_t::operter_zuo(Mat& temp) { Mat out; cv::add(temp, Scalar(50, 50, 50), out);//divide //out = temp + Scalar(50, 50, 50); return out; } void opencv_t::tar_bar(Mat& temp) { namedWindow("亮度调整", WINDOW_AUTOSIZE); int max = 100; int lisss = 50; } static void ontrack(int lit,void* temp )//回调 { Mat image = *((Mat*)temp); Mat out; lit= lit - 50; cv::add(image, Scalar(lit, lit, lit), out); imshow("亮度调整22", out); } void opencv_t::bar_demo(Mat& temp) { namedWindow("亮度调整22", WINDOW_AUTOSIZE); int lit = 50; int max = 100; createTrackbar("valuebar", "亮度调整22", &lit, max, ontrack,(void*)(&temp)); ontrack(50, &temp); } void opencv_t::color_sectect(Mat& temp) { namedWindow("风格变换", WINDOW_AUTOSIZE); int c = -1;//signal Mat dst; while (true) { cin >> c; if (c == -1) { imshow("风格变换", temp); waitKey(1); } else { c = c % 22; applyColorMap(temp, dst, colormaps[c]); imshow("风格变换",dst); waitKey(1); } } } Mat opencv_t::operter_chen(Mat& temp) { Mat out; multiply(temp, Scalar(2,2,2),out); return out; }