Sorry for the easy question but I looked for a long time for the proper way to do this and was unable to do this.
Now someone around here taught me how this is normally done and it is shamefully easy. Still I rather post the answer than delete the post.
So the solution is given the line, divide it so that the space between each point is the same as the space between bins in the original histogram.
For each point consider the 4 nearest neighbours and interpolate the value at the point.
To integrate over a certain distance perpendicular to the line, create several lines parallel to the first up to the desired distance and with space between each line equal to the spacing between bins in the original histogram. Sum the lines.
I think this should maintain the total number of counts equal.
If you have any opinions please share.