How to plot histogram of difference of two images using MATLAB i would like to calculate difference of two images. Then, histogram of difference of two images. So I can plot a histogram but I am not sure whether it is true or not? Also, I am not sure about what should be second parameter of built-in histogramfunction.

My two images are original_result and output_image. And difference of two image is image_of_dif.
my result: 

image_of_dif = double(original_result) - double(output_image);
figure; histogram(image_of_dif(:), 511);
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.