Vote count:
0
So I'm basically trying to implement a basic image compression algorithm using quadtrees in java; however, I'm really stuck on how to turn anything more than four pixels into a quadtree. My gut feeling is recursion.
Basically right now, this is my idea. This obviously only works for an image with 4 pixels. I'm not should how I would dig deeper into the image array.
if(sideLength == 2){
QuadNode parent = new QuadNode(image.length);
for(int i = 0; i < image.length; i++){
for(int j = 0; j < image[0].length; j++){
QuadNode child = new QuadNode(image[i][j], image.length/2);
if (j == 0 && i == 0)
parent.setQuadrant(UpperLeft, child);
if (j == 0 && i == 1)
parent.setQuadrant(LowerLeft, child);
if (j == 1 && i == 0)
parent.setQuadrant(UpperRight, child);
if (j == 1 && i == 1)
parent.setQuadrant(LowerRight, child);
}
}
return new QuadTree(parent);
}
asked 33 secs ago
Image Compression using Quadtrees Algorithm
Aucun commentaire:
Enregistrer un commentaire