# How to make a scatter plot from 2 images [closed]

How can two images be used to create a scatter plot, image 1 being the x axis, image 2 being the y axis, and the color of each plot point being the bin count?

• Can you explain further, please? Do you have an example? Do you have any code? – Dr. belisarius Sep 18 '13 at 1:24
• Something like this post ? – Vitaliy Kaurov Sep 18 '13 at 3:13
• @sak please clarify exactly what you mean by "image 1 being the x axis". Assuming color images how do you propose to map a color value to a scalar? – george2079 Sep 18 '13 at 12:54

Something like this?

First, I Import the pictures, in this case a stereogram pair from Wikipedia (so that I have reasonably similar images; this to make the exercise somewhat interesting). I split them using ImagePartition and then extract the Hue information using a color space conversion and successive extraction of the H part of the HSB representation of the image pixels. SmoothDensityHistogram does the rest.

fileLoc="http://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Asiatic_hybrid_lilium_stereogram_flipped.jpg/800px-Asiatic_hybrid_  lilium_stereogram_flipped.jpg"
{pic1, pic2} =
Flatten[
ImageData[
ColorConvert[#, "HSB"]][]
] & /@ Flatten@ImagePartition[#, ImageDimensions [#] {1/2, 1}] &@Import[fileLoc];

SmoothDensityHistogram[
Transpose[{pic1, pic2}],
Method -> {"DistributionAxes" -> "SmoothHistogram"},
ColorFunction -> ColorData["SunsetColors"]
] Original picture: • Assume image1 and image2 contain gray scale intensity values 0..255. To create the scatter plot, take corresponding pixels from each image at row,col, then use the value from image1 as the cartesian x coordinate, and the value from image2 as the cartesian y coordinate, and plot the point on a graph, binning the results like a 3D histogram to show population and add false color showing bins with high counts. – sak Sep 18 '13 at 22:24
• @sak I trust you will be able to easily adapt the answer above to the demands of your homework assignment. Please be more specific in your question next time. I note you refer to the color of the pictures whereas they happen to be B/W now. – Sjoerd C. de Vries Sep 19 '13 at 13:50