2010-11-16 186 views
2

我有一个大小为'n'的方阵,它由数字(1到N)不规则但聚集而成。例如,所有7个一起,所有10个一起等等,但是不规则。使用“图像和色彩映射”命令,我得到一个矩阵,其中每个聚类的颜色不同,但具有方形边缘。现在我想弄皱边缘,以便每种颜色之间有平滑的边界。基本上我需要斜坡代替步骤!我是MATLAB的初学者。 Pl帮助...........平滑颜色图图像中的边缘

回答

0

您可以尝试对图像进行过采样,并通过低通滤波器输入。

3

您可以使用任何类型的低通滤波器(即平滑)来卷积数组。如果您希望斜坡是直线,则可以使用平均过滤器;如果你想斜坡是S形,你可以使用高斯滤波器。过滤窗口的大小决定了斜坡的宽度。

例如,使用3×3平均滤波器(这将给宽度3像素的坡道),你会执行下列步骤:

%# pad the image by twice replicating borders to avoid border effects 
%# use padarray instead if you have the image processing toolbox 
tmp = img([1 1 1:end end end],[1 1 1:end end end]); 
%# apply the convolution. Normalize the filter so that the sum 
%# of all pixels in the filter is 1, and use the 'valid' option 
%# to automatically discard the padding. 
smoothImg = conv2(tmp,ones(3)/9,'valid'); 
0

显示使用令pColor图像,然后键入阴影的interp

pcolor(matrix); %or pcolor(x,y,matrix) 
shading interp;