当前位置:网站首页>Opencv learning notes -day13 pixel value statistics calculation of maximum and minimum values, average values and standard deviations (use of minmaxloc() and meanstddev() functions)
Opencv learning notes -day13 pixel value statistics calculation of maximum and minimum values, average values and standard deviations (use of minmaxloc() and meanstddev() functions)
2022-06-30 08:48:00 【Chasing foot dream】
OpenCV Learning notes
day13 Pixel value statistics
function
CV_EXPORTS_W void minMaxLoc(InputArray src, CV_OUT double* minVal,
CV_OUT double* maxVal = 0, CV_OUT Point* minLoc = 0,
CV_OUT Point* maxLoc = 0, InputArray mask = noArray());
| Parameters | explain |
|---|---|
| src | Enter a single channel array ( Images ) |
| minVal | double* type , The minimum value that the pointer points to . If there is no need to return , This value is set to NULL |
| maxVal | double* type , The maximum value that the pointer points to . If there is no need to return , This value is set to NULL |
| minLoc | Point* type , The pointer points to the position of the minimum value ( In two dimensions ). If there is no need to return , This value is set to NULL. |
| maxLoc | Point* type , Returns the pointer to the maximum position ( In two dimensions ). If there is no need to return , This value is set to NULL |
| mask | Optional mask for selecting subarrays |
notes:1,minMaxLoc For single channel images ,minMaxIdx There is no limit to ( However, the output coordinates will become three-dimensional ).
2, The first 6 Two parameters are optional (optional), No use, no transfer
example 1
minMaxLoc(mv[i], &minv, &maxv, &minLoc, &maxLoc, Mat());
// Statistics of single channel images mv[i] The maximum and minimum values in and the pointer to the maximum and minimum values
//minMaxLoc() function The input image (mv[i]) Single channel is required
CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev,
InputArray mask=noArray());
| Parameters | explain |
|---|---|
| src | Input array ( Images )1-4 All channels are OK |
| mean | mean value |
| stddev | Standard deviation |
| mask | Optional mask for selecting subarrays |
example 2
meanStdDev(image, mean, stddev);
// Statistics image The mean and standard deviation of the three channels
When printing mean.at< double >(0, 0),mean.at< double >(1, 0),mean.at< double> (2, 0)
Represent the mean values of the three channels respectively ,mean.at< double >(0, 0),mean.at< double >(0, 1),mean.at< double >(0, 2), They also represent the mean values of the three channels and correspond to the first three one by one ,
The standard deviation is the same
stddev.at< double >(i,0)
Code
quickopencv.h
#pragma once
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
using namespace cv;
// Defining classes
class QuickDemo{
public:
void colorSpace_Demo(Mat &image);// Color space conversion function 2021-12-24
void mat_creation_demo(Mat &image);//Mat Object and creation 2021-12-27
void pixel_vist_Demo(Mat &image);// Read and write operation of image pixels 2022-1-3
void operators_demo(Mat &image);// Arithmetic operation of image pixels 2022-1-4
void tracking_bar_demo(Mat &image);// Scroll bar operation demonstration 2022-1-7
void key_demo(Mat &image);// Keyboard response operation 2022-1-12
void color_style_demo(Mat &image);//OpenCV With color table operation 2022-1-12
void bitwise_demo(Mat &image);// Bit operation ( Logical operation )2022-1-17
void channels_demo(Mat &image);// Channel separation and merge 2022-1-17
void inrange_demo(Mat &image);//roi Region extraction 2022-1-20
void pixel_statistic_demo(Mat &image);// Pixel value statistics 2022-1-21
};
QuickDemo.cpp
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
#include<quickopencv.h>
#include <iostream>
void QuickDemo::pixel_statistic_demo(Mat &image)
{
double minv, maxv;
Point minLoc, maxLoc;// Location
std::vector<Mat> mv;
split(image, mv);// The channel separation
for (int i = 0; i < mv.size(); i++)
{
minMaxLoc(mv[i], &minv, &maxv, &minLoc, &maxLoc, Mat());//minMaxLoc() function Input image requires a single channel
std::cout << "No.vhannels." << i << " min value " << minv << " max value " << maxv << std::endl;
}
Mat mean, stddev;//mean: Average stddev: variance
meanStdDev(image, mean, stddev);
//CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev,InputArray mask = noArray());
std::cout << "means:" << mean << std::endl;
std::cout << "stddev:" << stddev << std::endl;
// Print separately
for (int i = 0; i < mv.size(); i++)
{
std::cout <<"means:"<< mean.at<double>(i, 0) <<"----"<<"stddev:"<<stddev.at<double>(i,0)<< std::endl;// Single channel print average
}
}
OpencvTest.cpp
#include <iostream>
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
#include<quickopencv.h>
using namespace cv;
using namespace std;
int main()
{
Mat scr = imread("D:\\ Study \\OpenCV Study \\pictures\\image\\ Green screen Pikachu .jfif");// Open a picture
if (!scr.data == 1)// Sentenced to empty
return -1;
namedWindow(" window 1", WINDOW_NORMAL);// establish WINDOW_FREERATIO window
imshow(" window 1",scr);// Show in the created window
QuickDemo qd;
qd.pixel_statistic_demo(scr);
waitKey(0);
return 0;
}
result :
边栏推荐
- Redis设计与实现(一)| 数据结构 & 对象
- QT connection to Shentong database
- Redis design and Implementation (V) | sentinel sentry
- How to format an UTC date to use the Z (Zulu) zone designator in php?
- layer.open 当传值为数组或值太长时处理方法
- Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which
- Deploy the cow like customer network project on the ECS
- Enhance the add / delete operation of for loop & iterator delete collection elements
- 小心transmittable-thread-local的这个坑
- 从0开始构建一个瀚高数据库Docker镜像
猜你喜欢

Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which

C#访问MongoDB并执行CRUD操作

Use Huawei performance management service to configure the sampling rate on demand

Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush

Pytorch BERT

El input limit can only input numbers
![[untitled]](/img/b8/e3f54fe5d1079663799887e62cb07c.jpg)
[untitled]

Interpretation of orientedrcnn papers

TiDB 6.0:让 TSO 更高效丨TiDB Book Rush

Deploy the cow like customer network project on the ECS
随机推荐
Comparison of two ways for C to access SQL Server database (SqlDataReader vs SqlDataAdapter)
Viteproject require Syntax Compatibility Problem Solving require is not defined
Deploy the cow like customer network project on the ECS
从0开始构建一个瀚高数据库Docker镜像
[kotlin collaboration process] complete the advanced kotlin collaboration process
Gilbert Strang's course notes on linear algebra - Lesson 1
Mmdet line by line code interpretation of positive and negative sample sampler
Torchvision loads the weight of RESNET except the full connection layer
Pytorch BERT
Evaluation standard for audio signal quality of intelligent speakers
CUDA implements matrix replication
PHP API to obtain QR code and combine to generate pictures
Flink SQL custom connector
El input limit can only input numbers
Rew acoustic test (V): equipment required for test
php api获取二维码、组合生成图片
This point in JS
layer. Open processing method when the passed value is an array or the value is too long
Sort (simple description)
Maxiouassigner of mmdet line by line interpretation