Generating data on an unlevel background

I want to create a non-original background and then generate some test data using Matlab. I was unclear when I asked this question before. 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 are already defined, it displays it on a flat surface. I do not want to distort the function itself, but I want the surface on which it passed to be inexpressive, to some extent changed, or something like that. Hope it's a little clearer.

+2


a source to share


1 answer


You create the background the same way you create a signal, or a foreground: using a function that applies a value to each pixel. Then you add foreground to background and you're done.

The NDGRID function will probably be useful for you.



For example, you can write:

%# 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,[])

      

+1


a source







All Articles