1
votes

I have obtained the following figure using a 120x120 matrix and the surf function.

enter image description here

Is there a simple way to make the lines between different colors look smoother?

1
Zooming out could do the trick. (Perhaps preceded by using a higher initial resolution) - Dennis Jaheruddin
How did you calculate the lines? - Dan
@Dan: This is the result of an optimization problem, and the resulting matrix is piecewise constant on the hexagons. The lines are made by the surf function, not by me. But I guess that the only option is to tune the image myself, or use another software to manage the data. - Beni Bogosel
@DennisJaheruddin: Higher initial resolution means higher computational costs for my program. I would like that, but the algorithm which gives this is not that fast. And I cannot zoom out, since this is the complete image. - Beni Bogosel
What if you increase the resolution after calculating the image using nearest neighbour interpolation? - Dan

1 Answers

3
votes

First of all, surf may not be the best way to display 2D-image - if you don't actually need the height information, imagesc will work just fine. Even better, it won't show the differently colored lines between hexagons, since it's not going through the colormap at intersections.

However, regardless of your approach, a low-resolution bitmap will not be automatically transformed into a "arbitrary"-resolution vector graphics - and you may not want that, anyway, if you use the figure to allow you to inspect at which combination of (x,y) you obtained at a given value.

There are three approaches to make your image prettier - (1) segment the hexagons, and use patch to create a vector-graphics image. (2) upsample the image with imresample. (3) create a RGB image and smoothen each color separately to get softer transitions:

%# assume img is your image
nColors = length(unique(img));
%# transform the image to rgb
rgb = ind2rgb((img+fliplr(img)),jet(nColors)); %# there are much better colormaps than jet
%# filter each color
for i=1:3,rgbf(:,:,i)=imfilter(rgb(:,:,i),fspecial('gaussian',9,3),'replicate');end