A distribution of values
For a grayscale image, a histogram groups intensity values into bins and counts the pixels in each group. It can show whether values occupy a narrow range or collect near one end. The bin definition matters: broad groups hide distinctions that narrower groups may reveal. Neither choice records the positions of the pixels.
Hypothetical example: stripes and checks
Make two square pictures using equal numbers of dark and light cells. Arrange one as a checkerboard and the other as two solid vertical stripes. Their intensity counts match, even though the pictures look very different. Moving the cells changes the structure while preserving the distribution. A matching histogram therefore cannot establish that two images contain the same shapes.
Use a second view
Read the histogram together with the image and a description of how values are represented. A large concentration of dark pixels could be appropriate for a night scene or unexpected for a bright background. The count alone cannot settle that question. Color-channel histograms also need interpretation; separate channel counts do not preserve every relationship among colors at individual positions.
Identify what the summary counts before deciding whether it can answer a spatial question.
Further reading: MathWorks: creating an image histogram.