how to plot x y over time
4 views (last 30 days)
Show older comments
this is te first time i used MATLAB i have eyetrack record like this
eyetrackRecord =
struct with fields:
x: [1.3756e+03 1.3734e+03 1.3798e+03 1.3789e+03 … ] (1×5128 double)
y: [416.1000 415.5000 416.6000 410.8000 … ] (1×5128 double)
pa: [1416 1423 1423 1421 1420 1424 1431 1417 … ] (1×5128 double)
t: [281349 281395 281403 281409 281418 281423 … ] (1×5128 double)
missing: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 … ] (1×5128 double)
How can I plot the moving heatmap of gazing over the video file in MATLAB
0 Comments
Answers (1)
Yash
on 4 Oct 2024
Hi @Korrawit
Since you have the "eyetrackRecord" data variable, you can ustilise the hist3 function to get the heatmap.
numBins = [100, 100];
% Sample data
numPoints = 5000; frameWidth = 1920; frameHeight = 1080;
x = frameWidth * rand(1, numPoints);
y = frameHeight * rand(1, numPoints);
% Create a 2D histogram of the gaze data
heatmapData = hist3([y', x'], 'Nbins', numBins);
% Normalize
heatmapData = heatmapData / max(heatmapData(:));
% Display the heatmap
figure;
imagesc(heatmapData);
colormap('jet'); % Use a colormap to represent the heat values
colorbar;
title('Gaze Heatmap'); xlabel('Horizontal Position'); ylabel('Vertical Position');
axis equal;
set(gca, 'YDir', 'normal'); % Flip the Y-axis to match the image coordinates
I hope this helps!
0 Comments
See Also
Categories
Find more on Data Distribution Plots 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!