www.gusucode.com > images 案例代码 matlab源码程序 > images/ComputeIntegralImageOf3DInputImageExample.m
%% Compute Integral Image of 3-D Input Image % %% % Create a 3-D input image. % Copyright 2015 The MathWorks, Inc. I = reshape(1:125,5,5,5); %% % Define a 3-by-3-by-3 sub-volume as |[startRow, startCol, startPlane, % endRow, endCol, endPlane]|. [sR, sC, sP, eR, eC, eP] = deal(2, 2, 2, 4, 4, 4); %% % Create an integral image from the input image and compute the sum over a % 3-by-3-by-3 sub-volume of I. J = integralImage3(I); regionSum = J(eR+1,eC+1,eP+1) - J(eR+1,eC+1,sP) - J(eR+1,sC,eP+1) ... - J(sR,eC+1,eP+1) + J(sR,sC,eP+1) + J(sR,eC+1,sP) ... + J(eR+1,sC,sP) -J(sR,sC,sP) %% % Verify that the sum of pixels is accurate. sum(sum(sum(I(sR:eR, sC:eC, sP:eP))))