# How to interpolate data and create a Density Plot?

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: White represents 1's and blacks represents 0's.

How do I do this?

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

myData = {{#[], #[]}, #[]} & /@ 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}]

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