以下代碼產生錯誤:Matlab的:AlphaData的警告尺寸必須匹配CData的
Warning: Dimensions of AlphaData must be 1x1, or must match CData.
的問題是,CData是一個彩色圖像,因此具有3個維度,並且alphadata是transparancy數據ABD的矩陣因此有2個維度。
red = cat(3, ones(512), zeros(512), zeros(512));
mask = [];
bounds = data(currow,1:6);
if slice >= bounds(5) && slice <= bounds(6)
mask = zeros(size(segmask,1),size(segmask,2));
mask(bounds(1)-4:bounds(2)+4,bounds(4)+4:bounds(4)+5) = 1;
mask(bounds(2)+4:bounds(2)+5,bounds(3)-4:bounds(4)+4) = 1;
end
imshow(low(:,:,slice),[WL-WW/2 WL+WW/2])
hold on
h = imshow(red);
set(h, 'AlphaData', 0.3*mask);
hold off
這裏是從MATLAB文檔
AlphaData m-by-n matrix of double or uint8
Transparency data. A matrix of non-NaN values specifying the transparency of each face or vertex of the object. The AlphaData can be of class double or uint8.
MATLAB software determines the transparency in one of the following ways:
Using the elements of AlphaData as transparency values (AlphaDataMapping set to none)
Using the elements of AlphaData as indices into the current alphamap (AlphaDataMapping set to direct)
Scaling the elements of AlphaData to range between the minimum and maximum values of the axes ALim property (AlphaDataMapping set to scaled, the default)
CData matrix | m-by-n-by-3 array
The image data. A matrix or 3-D array of values specifying the color of each rectangular area defining the image. image(C) assigns the values of C to CData. MATLAB determines the coloring of the image in one of three ways:
Using the elements of CData as indices into the current colormap (the default) (CDataMapping set to direct)
Scaling the elements of CData to range between the values min(get(gca,'CLim')) and max(get(gca,'CLim')) (CDataMapping set to scaled)
Interpreting the elements of CData directly as RGB values (true color specification)
Note that the behavior of NaNs in image CData is not defined. See the image AlphaData property for information on using transparency with images.
AlphaData和CDATA怎麼可能有SMAE尺寸上AlphaData和CDATA的信息?
如果紅色是512x512x3和掩碼是512×512和除警告代碼似乎進行正常操作。
你檢查是否'尺寸(屏蔽)'是一樣的'尺寸(紅(:,:,1))'? – 2012-07-13 20:23:08
您可能想完成您的問題? – mathematician1975 2012-07-13 20:23:14
是的,H.Muster他們是相同的大小。 – James 2012-07-13 20:38:18