Let's say I have two images. One is the original and the other is after some photo-manipulation has been applied to it.

I want to show the effect on the color saturation using a scatter chart. Similar to this:


How would I do that?


1 Answer 1


Suppose these are img1 and img2 (in this example img2 is a Deuteranopia colour blindness effect with some contrast adjustment):

img1 img2

You first convert them to the "HSB" colour space using ColorConvert[img1,"HSB"] and likewise for img2. All you then need to do is extract the values in the Saturation channel and pair them up:

points = Transpose[
 Flatten[ImageData[ColorConvert[#, "HSB"]], 1][[All, 2]] & /@ {img1,img2}];

oldcols = RGBColor /@ Flatten[ImageData[img1], 1];

 Graphics[Riffle[oldcols, Point /@ points]],
 Plot[x, {x, 0, 1}, PlotStyle -> Red],
 Frame -> True, 
 FrameLabel -> {"Input Saturation", "Output Saturation"},
 AspectRatio -> 1]

enter image description here


You learn something new every day it seems... Today I found the function ChromaticityPlot which can also be used quite nicely to see what image effects do to colours. Notice how the right image shows the blues and yellows have been stretched out but all other colours have been flattened onto a line (as expected from a colour blindness effect):


  {ChromaticityPlot[img1, PlotLabel -> "Before"],
  ChromaticityPlot[img2, PlotLabel -> "After"]}, 
 ImageSize -> 512]
  • $\begingroup$ Thanks so much! I am an absolute beginner, so I have no idea how to change the color points though. Could you help me with this too? It would look a lot prettier with the colors :)) $\endgroup$ Commented Jun 6, 2015 at 11:28
  • $\begingroup$ @AmyNeville I have updated my answer, I'm also no longer using ListPlot but switched to Graphics for speed reasons. $\endgroup$
    – Histograms
    Commented Jun 6, 2015 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.