解决与Python的图片难题

时间:2012-03-28 08:41:51

标签: python python-imaging-library python-2.7

  

你有2000个原始图像,52x52像素,RGB 24位,对应   表示4000x1250像素图像的拼图。

     

每对相邻图像在1行/列像素上重叠。边界   图像具有重复的像素行/列。尝试重建   难题。

我正在考虑使用PILOpenCV,也许还有其他库

修改

有人这样做了

private function runAlgorithm(index:int):void
{
    var currentBitmap:Object = allBitmaps[index];
    if(currentBitmap.visited) return;
    currentBitmap.visited = true;

    var left:int = leftMap[currentBitmap.leftRow];
    var right:int = rightMap[currentBitmap.rightRow];
    var top:int = topMap[currentBitmap.topRow];
    var bottom:int = bottomMap[currentBitmap.bottomRow];

    if(left != -1){
        allBitmaps[left].bitmap.x = currentBitmap.bitmap.x - 50;
        runAlgorithm(left);
    }
    if(right != -1){
        allBitmaps[right].bitmap.x = currentBitmap.bitmap.x + 50;
        runAlgorithm(right);
    }
    if(top != -1){
        allBitmaps[top].bitmap.y = currentBitmap.bitmap.y - 50;
        runAlgorithm(top);
    }
    if(bottom != -1){
        allBitmaps[bottom].bitmap.y = currentBitmap.bitmap.y + 50;
        runAlgorithm(bottom);
    }
}

如果这是正确的方法,我将需要在python中编写类似的代码或代码

1 个答案:

答案 0 :(得分:0)

使用numpy我会用小的52x52矩阵制作一个大矩阵。每个条目都是3元素元组(R, G, B)

要加入较小的矩阵,您可以使用hstackdef)和vstackdef)。

相关问题