Azimuth data: Colormap wrapping when performing interpolation
4 views (last 30 days)
Show older comments
William Thielicke
on 18 Feb 2019
Answered: William Thielicke
on 21 Feb 2019
Hello,
I have a problem with interpolating a colormap for azimuth / circular data... Please check the attached images: The colormap (HSV) represents the direction of the vectors (ranging from -180 to +180 degrees). Red is left, cyan ist right, greenish is up and purple is down.
For several reasons, I would like to create a smooothed graphical output. That is why I upscale the dataset using the function 'imresize'.
But the result gives a strong line when the direction changes from -180 to +180 (for reasons that I understand, but I can't think of a workaround...).
Does someone have an idea how to prevent this colormap wrapping...? Thanks!!
0 Comments
Accepted Answer
Shunichi Kusano
on 21 Feb 2019
As you noticed, phase is discontinuous function. One can convert this to the continuous function, for example, by using cosine and sine functions, for which interpolation works.
%% generate original phase image
x = -1:0.1:1; % original x-coordinate
y = -1:0.1:1; % original y-coordinate
[X, Y] = meshgrid(x,y);
phase = angle(complex(X,Y)) * 180 / pi;
imagesc(phase);
colormap hsv;
% not-correct
figure,imagesc(imresize(phase, [100,100])),colormap hsv;
% phase is converted by cos and sin.
X = cos(phase/180*pi);
Y = sin(phase/180*pi);
% interpolation
X_interp = imresize(X, [100, 100]);
Y_interp = imresize(Y, [100, 100]);
% re-convert to phase
phase_interp = angle(complex(X_interp,Y_interp)) * 180 / pi;
figure, imagesc(phase_interp), colormap hsv;
hope this helps.
0 Comments
More Answers (1)
See Also
Categories
Find more on Orange in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!