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?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityLet'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?
Suppose these are img1
and img2
(in this example img2
is a Deuteranopia colour blindness effect with some contrast adjustment):
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];
Show[
Graphics[Riffle[oldcols, Point /@ points]],
Plot[x, {x, 0, 1}, PlotStyle -> Red],
Frame -> True,
FrameLabel -> {"Input Saturation", "Output Saturation"},
AspectRatio -> 1]
MORE:
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):
Image@GraphicsRow[
{ChromaticityPlot[img1, PlotLabel -> "Before"],
ChromaticityPlot[img2, PlotLabel -> "After"]},
ImageSize -> 512]
ListPlot
but switched to Graphics
for speed reasons.
$\endgroup$
Jun 6, 2015 at 23:49