Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Eye tracking heat map

64 views
Skip to first unread message

Matt Jones

unread,
Jul 28, 2016, 7:11:07 AM7/28/16
to
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.

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

Thanks in advance!!
Matt

Steven Lord

unread,
Jul 28, 2016, 9:29:05 AM7/28/16
to


"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

Matt Jones

unread,
Jul 28, 2016, 2:25:09 PM7/28/16
to
Thanks for your help, this is a good start. Just a few of issues though in terms of getting to where I need to be.

Firstly, the 'blobs' on the histogram are very faint. I can increase this by making fewer bins but this results in lots of squares rather than the smoother effect you normally get with these heat maps (such as the example in my original post). Any way to change the histogram to have this kind of appearance? I have seen other use gaussian methods to do this but this is a bit outside of what I know about.

Second, the image is upside down with this code. I don't know if it is just the image that is flipped or if it is both the histogram and the image. Any idea?

Third, even with the bins, the intensity of the blobs is still a bit too faint. Is there a way to increase the intensity of the blobs, so areas looked for a higher proportion are much more red?

Thanks
Matt

"Steven Lord" <Steve...@mathworks.com> wrote in message <nnd1aq$rn$1...@newscl01ah.mathworks.com>...
0 new messages