MATLAB exercise program (integral chart)

Source: Internet
Author: User

This is often used to calculate Haar features.

Wiki has a very good introduction. I turned to the following shame:

Each point of the integral graph (X,Y) Is the sum of all values in the upper-left corner of the source image:

In addition, the integral graph can be effectively calculated by traversing the image only once, because each point of the integral graph (X,Y) Value:

Once the integral graph is calculated, the sum of any rectangle can be calculated within the constant time. For example, the value of the Shadow rectangle area is as follows:

Clear all; close all1_clc1_img1_double(imread('lena.jpg '); [m n] = size (IMG); % calculate the integral graph I = zeros (m, n); for I = 1: M for j = 1: n if I = 1 & J = 1% integral image upper left corner I (I, j) = IMG (I, j ); elseif I = 1 & J ~ = 1% integral image first line I (I, j) = I (I, J-1) + IMG (I, j); elseif I ~ = 1 & J = 1% integral image first column I (I, j) = I (I-1, j) + IMG (I, j ); else % integral image other pixel I (I, j) = IMG (I, j) + I (I-1, j) + I (I, J-1)-I (I-1, J-1 ); end endend % How to Use I depends on the situation


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.