Updated source code

Changes doc - image integral function and margins have to be reviewed