如何在 Matlab polaraxes 上链接数据图像?

How to linkdata images on Matlab polaraxes?

我正在尝试 linkdata 极轴上的图像,这在 linkdata 文档 linkdata 中很好地描述了 plot/area/... 作为笛卡尔坐标 here. 第一段使用基于 alpha 值的剪切生成两个图像的代码。 第二部分循环并在极轴上绘制这些图像。 第一次迭代后,linkdata on 激活,但我收到的通知不提供 Fix it 选项,如图 1 所示。 我认为错误在于我无法将 linkdata 的数据源明确定义为图像,请参见尝试 1。 代码

close all; clear all; clc;
af = figure('Name', 'Do Not Touch');
%% Data generation
f = figure;
hax = axes(f);
rgb = 'peppers.png';
% http://blogs.mathworks.com/steve/2009/02/18/image-overlay-using-transparency/
rgb = imread('peppers.png');
I = rgb2gray(rgb);
h = imagesc(I, 'Parent', hax);
[M,N] = size(I);
block_size = 50;
P = ceil(M / block_size);
Q = ceil(N / block_size);
alpha_data = checkerboard(block_size, P, Q) > 0;
alpha_data = alpha_data(1:M, 1:N);
set(h, 'AlphaData', alpha_data.^2);
zeroFigureDecorations(hax); 
images{1} = getframe(hax);

[M,N] = size(I);
block_size = 50*2;
P = ceil(M / block_size);
Q = ceil(N / block_size);
alpha_data = checkerboard(block_size, P, Q) > 0;
alpha_data = alpha_data(1:M, 1:N);
set(h, 'AlphaData', alpha_data.^2);
images{2} = getframe(hax);

close all;
clearvars -except images;     

%% Polar
% 
fp=figure('Name', 'Test', ...
    'Position',[200 200 851 404],'Resize','off'); % only half circle on polaraxes although warp can do eclipses
ThetaTicks = 0*pi:pi/10:1*pi;
pax = polaraxes( 'ThetaAxisUnits', 'radians', ...
    'ThetaLim',[min(ThetaTicks) max(ThetaTicks)],...
    'Color','none',...
    'GridAlpha',1,...
    'GridColor',[1 1 1],...
    'ThetaTick', ThetaTicks, ...
    'ThetaDir', 'counterclockwise', ...
    'Parent', fp);
imax = axes('Parent', fp, 'Visible', 'off');
zeroFigureDecorations(imax); 

for image=images
    h = imagesc(image{1}.cdata, 'Parent', imax); 

    zeroFigureDecorations(imax); 

    linkdata on; 

    angleRadians=-pi;
    I = getframe(pax);
    I = I.cdata;
    [x, y, z]=makePolar(I, angleRadians);
    imax.Children = warp(x, y, z, I);
    set(imax,'view',[-180 -90],'Visible','off');
    axis(imax,'tight')
    pause(0.5);
end

function zeroFigureDecorations(ax)
axis(ax, 'tight');
set(ax, 'yTickLabel', []);
set(ax, 'xTickLabel', []);
set(ax, 'Ticklength', [0 0]); % 
colormap(ax, gray(1024));
box(ax, 'off');
axis(ax, 'off');
end

图1 单幅图像在极轴上是正确的,这里是在第二次迭代之后;顶部栏显示失败的 linkdata 尝试,并且不像通常

那样提供 Fix it 选项

尝试 1

显式设置 guihandlesdatasources 但没有效果可能是因为没有显式地将 linkdata 应用于图像作为数据源

...
myhandles = guihandles(fp); 
for image=images
    h = imagesc(image{1}.cdata, 'Parent', imax); 
    myhandles.output = h; 
    myhandles.yData = []; 
    myhandles.xData = []; 
    set(get(myhandles.xData, 'Children'), 'XDataSource', myhandles.xData);  
    set(get(myhandles.yData, 'Children'), 'YDataSource', myhandles.yData);  
    ...
end

MathWorks 的联系人

MATLAB 反馈论坛回答

The short answer is that polaraxes does support data linking, however it looks like you are using warp, which is creating a type of surface object that does not support data linking. There are workarounds for this, for example you might be able to modify the warp.m file to use surf rather than surface.

我正在处理有关该主题的服务请求。

MATLAB: 2016b
OS:Debian 8.5
MathWorks 服务请求:#02229120

MATLAB support answer是当前的,因为没有关于修复的开发计划

The short answer is that polaraxes does support data linking, however it looks like you are using warp, which is creating a type of surface object that does not support data linking. There are workarounds for this, for example you might be able to modify the warp.m file to use surf rather than surface.