0
所以我基本上試圖在java中使用四叉樹來實現基本的圖像壓縮算法;然而,我真的堅持如何將四個以上的像素變成四叉樹。我的直覺是遞歸。使用Quadtrees算法的圖像壓縮
基本上現在,這是我的想法。這顯然只適用於4像素的圖像。我不應該如何深入挖掘圖像陣列。
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);
}