# Recursive Method for Spliting an Image into 4 quadrants

Hi Everybody

I am trying to split an image (64*64 pixels), in to four quadrants. That means now i have four quadrants each of 32*32 pixels. Now i further want to divide one quadrant to 4 until it reaches the single pixel.

Please tell me a recursive code or an Algorithm to implement this.

THanks
###### Who is Participating?

Commented:
should be like this:

Class MyImage
{
public MyImage getPart( int x, int y, int width, int height );
}

List splitImage( MyImage TheImage, int x, int y, int width, int height )
{
if ( width > 1 && height > 1 )
{
List ret = new Arraylist();
ret.addAll( splitImage( TheImage.getPart( x,y,width/2, height/2 )) );
ret.addAll( splitImage( TheImage.getPart( x + width / 2 ,y,width/2, height/2 )) );
ret.addAll( splitImage( TheImage.getPart( x ,y+heght/2,width/2, height/2 )) );
ret.addAll( splitImage( TheImage.getPart( x + width / 2 ,y + height/2,width/2, height/2 )) );
return ret;
}
else
{
List ret = new ArrayList();
}
}
0

Commented:
This is all about recursion, and has few to do with the splitting:

void recursiveMethod(argument)   // What ever the argument may be.
{
if(argument is big enough to go on)   // Warning this is not JAVA but a META-notation
{
}
}

// This might look like nonsense, but THIS IS RECURSION.
You can apply it in several languages in several cases.

The critirium for you is:  when doesn't it make sense to go on.
Like: when is the given image too small for a reasonable split.

;JOOP!
0

Author Commented:
I need some code... that will make it easy for me to understant
0

Commented:
in the inside (recursive) calls gives a 'piece of picture' as argument to the next level of recursion.
that meand that the method itself must have a 'piece of picture' as parameter. it is that piece of picture that is then split into quarters inside.

We really cannot help more than that, as this is obviously a homework assignment.

Anuway look a scuriwaress pseudocode carefully. once you 'get' the idea the coding is pretty easy.

regards JakobA
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.