1
votes

My goal is to create a heatmap in Matlab using an existing floor plan, and manually collected RF RSSI values.

I have marked numerical values (~30 to ~80) on a floor plan using pen and paper after recording signal strength in various areas of a building. I am looking to plot this in a heatmap overlay to the original floor plan.

What I have done is the following:

Google. YouTube. Man pages. My research has landed me accomplishing the following:

  • Importing an image to Matlab by asking the user to select a photo
  • Write it to the imread() function
  • Set an array the size of the image, all zeroed out
    • This is currently done manually, but not a concern right now
  • Manually placing, heatmap(x,y) = val; in locations marked on the original plan
    • I have found the x,y pixel coordinates from Photoshops info pallet
  • used a Gaussian low pass filter on the points set by heatmap()
    • The filter argument includes the image dimensions in pixels

At this point, I try to display the filtered heatmap()-ed points over the original floor plan. I am using the same dimensions for the filtering and the array made from the image size, in pixels. However, I am not getting the heatmap points to overlay where I specified by hard coding it.

The code is as follows:

%Import an image***********************************************
%Ask a user to import the image they want 
%**************************************************************

%The commented out line will not show the file type when prompted to select
%an image
%[fn,pn] = uigetfile({'*.TIFF,*.jpg,*.JPG,*.jpeg,*.bmp','Image files'}, 'Select an image');

%This line will select any file type, want to restrict in future
[fn,pn] = uigetfile({'*.*','Image files'}, 'Select an image');
importedImage = imread(fullfile(pn,fn));

%Create size for heat map**************************************
%Setting the size for the map, see comments below
%**************************************************************

%What if I wanted an arbitrary dimension
%Or better yet, get the dimensions from the imported file
heatMap = zeros(1512,1080);


%Manually placing the heatmap values along a grid
%Want to set zones for this, maybe plot out in excel and use the cells to
%define the image size?
heatMap(328,84) = .38;
heatMap(385,132) = .42;
heatMap(418,86) = .40;
heatMap(340,405) = .60;
heatMap(515,263) = .35;
heatMap(627,480) = .40;
heatMap(800,673) = .28;
heatMap(892,598) = .38;
heatMap(1020,540) = .33;
heatMap(1145,684) = .38;
heatMap(912,275) = .44;
heatMap(798,185) = .54;


%Generate the Map**********************************************
%Making the density and heat map
%**************************************************************
gaussiankernel = fspecial('gaussian', [1512 1080], 60);
density = imfilter(heatMap, gaussiankernel, 'replicate');

%imshow(density, []);
oMask = heatmap_overlay(importedImage, density, 'summer');
set(figure(1), 'Position', [0 0 1512 1080]);
imshow(oMask,[]);
colormap(summer);
colorbar;

Any idea why the overlayed filter is offset and not where specified?

This can be reproduced by any image 1512 x 1080
Please let me know if you want the original image used

1

1 Answers

0
votes

The array was off.
What I did was the following:

  • Output the density map only
  • Verified dimension sizes in the Matlab Workspace

I have noticed the array for the density, heatMap, importedImage and oMask were not all n x m size.

heatMap and importedImage were n x m, and importedImage and oMask were m x n.

I swapped the dimensions to all be n x m and now the image overlays just fine.