[Insight-users] How to create a set of spatially distributed images

Christian Marshall Rieck rieck at stud.ntnu.no
Mon Jan 8 06:54:11 EST 2007


> I am trying to simulate an image like this:
>  
> http://ftp.sv.vt.edu/pub/projects97/pvlachos/pvlachos_project/images/piv.gif
>  
> I started with creating small sized GaussianImageSource instances and pasting them at random positions on a background using PasteImageFilter. The problem is when two GaussianImageSource overlap as it can be seen in thios sample: http://img81.imageshack.us/my.php?image=testyz7.png
>  
> (2) If not, how to get rid of the ovelaping problem?

First thing that fell into my head:
You could 
instantiate an int/bool array[][] img  with your image size. Everytime you 
paste to some location (x,y) you set img[x][y] = 1/true. (also set all 
pixels covered by this image). Next time you want to paste to the image 
check the pixels you are going to paste into to se if there is an image 
there alredy. If there is, choose a new one.

As the number of places a new image fits in the larger image the 
while(find_a_suitable_place) loop may take some time. I am sure you can 
come up with something clever to speed this up.

Example: 
If your small images are 10x10 and you past to (0,0) you set 
img[0..10][0..10] = 1. 
If you try to paste the next small image to (2,2) (i guess you use a 
random-function for this) you check img[2..12][2..12]. Since these are not 
0 you must search for a new location.

Christian.



More information about the Insight-users mailing list