In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail about the use of OpenCV in C++ to achieve integral map calculation, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
How to use integral Images
Suppose that there are four points ABCD in an image, and the value of point A (x1Grainy1) in the integral image is the sum of the values of all the pixels on the upper left, that is, the sum of the values of all the pixels in the blue region. In the same sense integral image, the point values of B (x2), C (x1) and D (x2) are the summation of the pixel values in green, purple and yellow regions, respectively. The position relationship of the four points of ABCD is shown in the lower right corner.
Then if you need to calculate the cumulative value of ROI consisting of ABCD, you only need to use the following formula:
Namely: D-C-B+A. Obviously, the amount of calculation is not affected by the size of the region. Therefore, if you need to calculate the sum of pixels on areas of multiple sizes, it is best to use an integral image.
API of integral image
Void integral (InputArray image,OutputArray sum, int sdepth=-1)
Void integral (InputArray image,OutputArray sum, OutputArray sqsum, int sdepth=-1)
Void integral (InputArray image,OutputArray sum, OutputArray sqsum, OutputArray tilted,int sdepth=-1)
Function parameters:
Image input W × H source image, 8bit character type, or 32bit or 64bit floating point matrix
Sum output (Widel1) × (H + 1) integral image, 32bit integer or 32bit, 64bit floating point matrix
Sqsum output (Widel1) × (H + 1) square integral image, double precision floating point matrix.
Tilted output (Wend1) × (H + 1) integral image rotated 45 °, the data type is the same as sum.
Bit depth of sdepth integral image sum or titled: CV_32S, CV_32F, or CV_64F
Note: the image calculated above must be row and col plus 1, because the edge is also calculated, and an error will be reported if you do not add one.
Code demonstration
Let's create a new project named opencv--integral, follow the configuration properties (VS2017 configure OpenCV common properties), and then write # include and main methods in the source file
Calculation integral diagram
Note that when creating sumii and sqsumii above, remember that the width and height of the source image are both + 1
Before the image is displayed, we need to normalize the normlize.
Normalization is to limit the data that needs to be processed (through some algorithm) to a certain range that you need. First of all, normalization is for the convenience of data processing, and the second is to ensure faster convergence when the program is running. The specific function of normalization is to induce the statistical distribution of unified samples. Normalization between 0-1 is the probability distribution of statistics, and normalization is the coordinate distribution of statistics in a certain interval. Normalization means unity, unity and unity.
In short, the purpose of normalization is to make the non-comparable data comparable, while maintaining the relative relationship between the two comparable data, such as the size relationship, or in order to make a map, it is difficult to make it on a graph, and the relative position on the graph can be easily given after normalization.
About C++ in the use of OpenCV to achieve integral map calculation is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.