"Matt Jones" <
jone...@cardiff.ac.uk> wrote in message
news:nncp87$9ke$1...@newscl01ah.mathworks.com...
> Hi all...
>
> I need to make a heap map for my eye tracking data. My data contains a
> list of x and y coordinates, so some areas of the picture have been looked
> at more than others. I want to overlay the heat map onto my original
> image that was used. I have looked up other posts, but none seem to get
> me where I want to be.
> Currently I have the 400px x 400px image loaded as a 'uint8' variable
> (400x400x3) called 'image'. I also have the gaze data loaded with all
> valid x and y coordinates - any gaze-points outside of the 400x400px area
> have been removed.
You probably want to use a different variable name, as IMAGE already has a
meaning in MATLAB that may be of use to you later on.
www.mathworks.com/help/matlab/ref/image.html
> I have run the hist3 function which creates a 3D plot in 50x50 bins that
> would be ideal to overlay. This is the code I used for this:
>
> hist3(gazedata,[50 50])
> set(get(gca,'child'),'FaceColor','interp','CDataMode','auto');
>
> I need to overlay this with my image to create something like this:
>
http://static.businessinsider.com/image/53c419dbeab8eacc2ee9455f/image.jpg
Here is a _very_ rough example, just to show the general concepts that I
think you can use to achieve what you want (or something close to what you
want.) In particular, HISTOGRAM2 has a number of properties that you can use
to modify its appearance.
% Read data
[x, map] = imread('landocean.jpg');
% Prepare figure (if MATLAB does not warn when you set FaceAlpha later on,
% you can remove this step from your process)
set(gcf, 'Renderer', 'painters')
% Create 2-D histogram plot
h = histogram2(x(:, :, 2), x(:, :, 3), 'BinMethod', 'integer',
'DisplayStyle', 'tile');
% Make the histogram transparent
h.FaceAlpha = 0.5;
% Prepare to plot the image
hold on
imagesc(h.XBinLimits, h.YBinLimits, x);
% Put the histogram plot on top of the image
uistack(h, 'top')
--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com