Heatmap and surf plot of same data is looking different. Also is there a better way to 2D smooth
Show older comments
Hello, I am trying to estimate the background of this image. One way I would like to try is to break the image up into small regions and take the minium value in each region and then peform a surface fit to these. The aim would be to then subtract this from my main image (one thing I definetly need is smoothness, i.e no sharp jumps between regions)
My raw image showing the regions

The min in each region is obtained via blockproc (data attached)
blockMin =
183.00 185.00 184.00 195.00 198.00 185.00 203.00
194.00 204.00 188.00 192.00 217.00 190.00 212.00
202.00 213.00 204.00 191.00 208.00 210.00 209.00
204.00 205.00 225.00 204.00 202.00 210.00 211.00
225.00 240.00 219.00 209.00 210.00 227.00 210.00
225.00 213.00 217.00 241.00 223.00 226.00 223.00
219.00 222.00 232.00 233.00 217.00 238.00 231.00
Very strangely, the heatmap and surf plot of the same data set is showing a difference (I know I must rotate the surf plot, but its clear the peak regions are in different positions (shown by green circles). On the heatmap, the value of 241 is on the 3rd row, yet on the surf plot its on the 2nd row and on the wrong column.

This is my code (Im showing the pure surf plot above, not the smoothdata2 version)
blockFwhm;
figure
h=heatmap(blockFwhm, 'Colormap',cool,'FontSize',10); % app.PanelScan,
h.CellLabelFormat = '%.0f';
figure
ax1=subplot(1,2,1); ax2=subplot(1,2,2);
surf(ax1,blockFwhm); colormap cool; colorbar
% Try to smotth the data *** Although this isn't very good so
% far
B=smoothdata2(blockFwhm);
s=surf(ax2,B); colormap cool;
1 Comment
Jason
on 19 Apr 2025
Accepted Answer
More Answers (0)
Categories
Find more on Color and Styling 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!







