How to plot histogram of difference of two images using MATLAB
In your second line, casting with uint8() will change a negative value to 0. Avoid casting or change to another type that supports negative values.