Keep in mind that a histogram simply gives a summary of the image's tonal
values. It tells us nothing about how the individual pixels are arranged.

To demonstrate this we'll contrive an image consisting of a visually continuous
tonal gradient. A gradient has tones that are spatially related because the
image elements are quantitatively ordered. That is similar tones are spatially contiguous.

fig. 6

To the right of fig. 6 is its histogram. In this image the tonal value of a pixel is
absolutely correlated with its location. Given a location we can predict what
the pixel will be.

Next, with some of the tools, we're going to push the pixels around randomly,
making sure as we move each pixel that its tone is unchanged:

fig. 7

As you can see the histogram is exactly the same as the gradient histogram,
but in fig. 7 the tonal value of a pixel is uncorrelated with its location.

Now, let's push the pixels around a bit more creatively:

fig. 8

Again
the histogram is exactly the same. Here the tonal value of a pixel has some
correlation with its location. Given a location we can predict with good
probability what its value will be.

The three pictures have exactly the same pixels and as a result their
histograms are exactly similar. How the pixels were arranged does not affect the
histograms. As far as the histogram function is concerned, it's looking at the
same picture in each of the three cases. Our visual sensibilities attach
significance and order to an image.

A bar in an image histogram aggregates
observations from the entire image