Hacker News new | past | comments | ask | show | jobs | submit login
Understanding image histograms with OpenCV (lmcaraig.com)
88 points by se7entyse7en on Dec 28, 2017 | hide | past | favorite | 12 comments

> In the case of 2D histograms the resulting plot will have the pixel intensities of a channel on the X-axis, the pixel intensities of another channel on the Y-axis, and the frequency is given by the color of the plot.

I'm still having a hard time understanding what exactly this represents and how to properly interpret it.

There's a nice overview here: https://svi.nl/TwoChannelHistogram

I don't know any professional photographers who use 2D histograms for editing, or whether you can actually plot them in Lightroom or Photoshop. However for scientific image processing it seems to be more useful.

OpenCV also has a tutorial: https://docs.opencv.org/3.3.1/dd/d0d/tutorial_py_2d_histogra...

But which of the 'coming chapters' it's referencing I have no idea.

It shows correlations between colors. Consider two images, one with lots of purple and one with equal amounts of red and blue. Since the color purple is equal parts red and blue, we don't expect to see much difference in the one dimensional histograms between the red/blue image and the purple image. On the other hand, when we look at the 2D histogram we do find such a difference. The purple image's 2D histogram will have large values near the diaganol (red scales with blue). The red/purple image might have no correlation depending on the image, or could possibly be anti-correlated, with a diaganol as before, but with negative slope.

"We can easily extend what we've done for the 2D histogram to calculate 3D histogram... Unfortunately we cannot visualize this histogram."

Why not? Couldn't you just create a 3D image?

You would only be able to see the outside "shell" of it.

There are visualization programs that will let you move through a 3D volume, slice by slice, as it were (along various axis). So this shouldn't be an issue.

It wouldn't be a 3D volume though. A 2D histogram is a 3D volume. A 3D histogram would require a 4D object, so it would be a case of "first build your hypercube..."

How about a 3D point cloud with dot size corresponding to intensity?

Something like this [0]? (Disclaimer, I made it)

[0] https://franciscouzo.github.io/image_colors/

Really, it's just easier to visualise it differently. I think it's our failing as beings rather than of the visualization method. We just aren't made for it.

But in a 2D histogram you encode the 3rd dimension with color. So if you use color to encode the 4th dimension, you can take slices through the 3rd and get a decent sense of what's going on. That's how MRI scans work.

BTW there are tools for visualizing and "touring" these kinds of slices in arbitrarily high dimensions: http://www.ggobi.org/demos/tour.html

Their “3d histogram” is a 4d image

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact