2

I want to make an unlevel background and then generate some test data on that using Matlab. I was not clear when I asked this question earlier. So for this simple example

for i = 1:10  
for j = 1:10  
f(i,j)=X.^2 + Y.^2  
end  
end  

where X and Y have been already defined, it plots it on a flat surface. I don't want to distort the function itself, but I want the surface that it goes onto to be unlevel, changed by some degree or something. I hope that's a little clearer.

4

1 回答 1

1

您创建背景的方式与创建信号或前景的方式相同:使用将值应用于每个像素的函数。然后你将前景添加到背景中,你就完成了。

函数NDGRID可能对您有用。

例如,您可以编写:

%# create x and y coordinates for every pixel in the image
[xx,yy] = ndgrid(1:10,1:10);

%# create foreground
foreground = xx.^2 + yy.^2;

%# create an angled background, where y = -10*x;
background = -xx*10;

%# show all
figure
subplot(1,3,1),imshow(foreground,[])
subplot(1,3,2),imshow(background,[])
subplot(1,3,3),imshow(foreground+background,[])
于 2010-05-06T22:28:37.950 回答