Azimuth data: Colormap wrapping when performing interpolation

10 ビュー (過去 30 日間)
William Thielicke
William Thielicke 2019 年 2 月 18 日
回答済み: William Thielicke 2019 年 2 月 21 日
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!!
azimuth_data.jpg

採用された回答

Shunichi Kusano
Shunichi Kusano 2019 年 2 月 21 日
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.

その他の回答 (1 件)

William Thielicke
William Thielicke 2019 年 2 月 21 日
ThabkThank you veryvery much for your helphelp!

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by