Changing the histogram itself doesn't affect the image matrix from which you calculated it directly.
However, as Luis has suggested in the comments, you can use histeq
. You need to give it an additional input - the histogram you want the output image to match (here, I
is your original image, and hgram
is your modified histogram matrix):
J = histeq(I,hgram);