以下代码产生错误: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