How to get the original Image matrix from the Integral Image of a N*N matrix?

2 views (last 30 days)
IF the original image matrix is represented by r=[ 1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]. Then it's integral image using the inbuilt 'integralImage' function is given by
0 0 0 0 0
0 1 3 6 10
0 6 14 24 36
0 15 33 54 78
0 28 60 96 136
Excluding first row and first column we get
1 3 6 10
6 14 24 36
15 33 54 78
28 60 96 136
My requirement is to obtain the original image from the given integral image provided.

Accepted Answer

Stephen23
Stephen23 on 13 Dec 2018
Edited: Stephen23 on 13 Dec 2018
A simple solution based on the explanation given on the integralImage help page:
>> II = [0,0,0,0,0;0,1,3,6,10;0,6,14,24,36;0,15,33,54,78;0,28,60,96,136]
II =
0 0 0 0 0
0 1 3 6 10
0 6 14 24 36
0 15 33 54 78
0 28 60 96 136
>> II(2:end,2:end)-II(2:end,1:end-1)-II(1:end-1,2:end)+II(1:end-1,1:end-1)
ans =
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

More Answers (1)

Diarmaid Cualain
Diarmaid Cualain on 18 Dec 2018
To supplement stephens answer, you can also use the Matlab function "diff":
>>II = [0,0,0,0,0;0,1,3,6,10;0,6,14,24,36;0,15,33,54,78;0,28,60,96,136]
>>diff(diff(II,1,2),[])
ans =
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!