1
$\begingroup$

I have data of the form:

image := {{0.1,0.5,0.8}, {0.8,0.9,0.001}...}

where the entries correspond to the following: {x-coordinate, y-coordinate, brightness} and the data does not correspond to every grid point. (Note the brightness is usually between 0 and 1.)

I wish to create a density graph in Mathematica based on the data to give the a graph similar to the following:

Density Graph

White represents 1's and blacks represents 0's.

How do I do this?

$\endgroup$
1
$\begingroup$

If you have to convert your data to the below form:

myData = {{#[[1]], #[[2]]}, #[[3]]} & /@ rawData;

Then:

myData = {{{1, 1}, 1}, {{1, 2}, 2}, {{1, 2.5}, 3}, {{1, 4}, 
   4}, {{2, 1}, 2}, {{2, 2}, 2}, {{2, 3}, 6}, {{2, 3.2}, 4}, {{3, 1}, 
   3}, {{3, 2}, 6}, {{3, 3}, 3}, {{3, 4.2}, 12}, {{4, 1.6}, 
   4}, {{4, 2}, 4}, {{4, 3}, 12}, {{4, 4}, 4}};

f = Interpolation[myData, InterpolationOrder -> All]

DensityPlot[f[x, y], {x, 1, 4}, {y, 1, 4}]
$\endgroup$
  • $\begingroup$ I want it to interpolate the data, as not all the squares are covered $\endgroup$ – Yahya Uddin Jan 12 '16 at 1:00
1
$\begingroup$
ListDensityPlot[
 Catenate@Table[{x, y, RandomReal[]}, {x, 1, 20}, {y, 1, 20}],
 PlotTheme -> "Monochrome"]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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