# Image Spit and Merge Algorithm based on Quadtree

Hi everybody

I just want to know is there any API for the image split and merge algorithm based on a quadtree. If anyone can provide this running algorithm , i would give as much as 3000 - 5000 points for the correct answer. It is urgent.

Thanks and Regards
Zubair
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
I think there isn't; I don't need 5000 points for this cutter:

/**
*  Cut a section out of an Image.
* <p>The addressed Image area may or may not overlap the given Image;<BR>
* the latter situation might produce an empty Image.<BR>
* The cut may also be from negative coordinates to produce empty space above or at left.<BR>
* If the Image is not fully loaded it is returned unchanged.</p>
*
* @param  picture     the initial picture.
* @param  fromX       the X-coordinate to cut from.
* @param  fromY       the Y-coordinate to cut from.
* @param  width       the cut width.
* @param  height      the cut height.
* @return             the resulting picture as an Image
*/
public static Image cut
(
Image picture, int fromX, int fromY, int width, int height
)
{
BufferedImage bi;
Graphics2D g;
int picWidth;                       // Dimensions of the picture.
int picHeight;
int picFromX;                       // Picket of the picture.
int picFromY;
int cutFromX;                       // Picket of the cut.
int cutFromY;
int bufferWidth;                    // Dimensions of the workspace.
int bufferHeight;

// Check the given picture :

if
(
(picWidth = picture.getWidth(null)) < 1
|| (picHeight = picture.getHeight(null)) < 1
)
{
return(picture);
}

// Compute the other measures :

if(fromX < 0)                    // Left side cut.
{
picFromX = -fromX;
cutFromX = 0;
bufferWidth = picWidth - fromX;
}
else
{
picFromX = 0;
cutFromX = fromX;
bufferWidth = Math.max(picWidth, fromX + width);
}

if(fromY < 0)                    // Top side cut.
{
picFromY = -fromY;
cutFromY = 0;
bufferHeight = picHeight - fromY;
}
else
{
picFromY = 0;
cutFromY = fromY;
bufferHeight = Math.max(picHeight, fromY + height);
}

// Create a new Image :

bi = new BufferedImage
(
bufferWidth, bufferHeight, BufferedImage.TYPE_INT_ARGB
);

// Paint the picture :

g = bi.createGraphics();
g.drawImage(picture, picFromX, picFromY, null);

// Cut the picture :

bi = bi.getSubimage(cutFromX, cutFromY, width, height);

// Produce the result :

return(Toolkit.getDefaultToolkit().createImage(bi.getSource()));
}

;JOOP!

Experts Exchange Solution brought to you by