I have 100 sensor nodes placed at coordinates (x and y) inside a 100*100 m2square field. I want to plot a heatmap showing proximity of all other locations to these sensor nodes
Show older comments
For example, if any location is within 10m of the sensor node, it should be coloured in red and if a location is far away from any node it should be coloured in blue. how can i generate such a heatmap 

Accepted Answer
More Answers (2)
Walter Roberson
on 18 Dec 2018
0 votes
4 Comments
Suniti
on 27 Dec 2018
Walter Roberson
on 3 Jan 2019
N = 100; %100 square meters
subpixels = 4; %each square meter divided into 4 x 4
sensorradius = 5;
gridN = N * subpixels;
NC = 256; %number of entries in colormap
fullmap = true(gridN, gridN);
usemap = bwdistgeodesic(fullmap, round(x(:)*subpixels), round(y(:)*subpixels)); %note it takes C, R which is X, Y
image(uint8(usemap))
colormap(flipud(jet(NC)))
values in usemap start at 0 and go up. 0 is right at a sensor. Any value up to (sensorradius * subpixels) is considered covered and needs to be colored red. Maximum possible value is (sqrt(2) * N * subpixels) for the case where there is one sensor at one corner, with the maximum distance being at the diagonal opposite corner.
The part about subpixels has to do with the fact that if you were to use 1 pixel per meter then a radius of 5 would involve only an 11 x 11 section, which gives a very crude circle, not even remotely as smooth as what you show in your image. To make a smoother image, we divide each square meter into a 4 x 4 area to give a much smoother approximation. Coordinates in x and y would still be given in meters, but the distance map will be constructed 4 times larger to make the appearance much smoother.
Suniti
on 9 Jan 2019
Walter Roberson
on 9 Jan 2019
Use a higher subpixels value until you are satisfied with the smoothness.
Categories
Find more on Volume Visualization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!










