2016-05-11 12 views
0

この特定のタスク(JES 4.3を使用)に問題があります。タスクは、Pythonを使用して25 x 25イメージにQRコードイメージを縮小し、イメージから白い枠線(静かなゾーン)を削除することです。私はそれを縮めることに何の問題もありませんが、静かなゾーンの除去は厄介です。私はスケーリング自体の前にそれを行わなければならないと信じており、静かなゾーン幅は変わる可能性があります。したがって、プログラムが静寂ゾーンではないことが検出されるまで、ピクセルの各外側レイヤーを1つずつ削除する必要があるようです。 whileループが必要であることは間違いありませんが、それを効果的に実装する方法はありません。ここまでのコード:Python(jython)を使用したQRコード操作 - 静音ゾーンのスケーリングと削除

def reduce(qrPicture): 
    file = makePicture(qrPicture) 
    myPicture = duplicatePicture(file) 


    width = getWidth(myPicture) 
    height = getHeight(myPicture) 



    newPicture = makeEmptyPicture(25, 25) 
    newWidth = getWidth(newPicture) 
    newHeight = getHeight(newPicture) 

    basePixel = getPixelAt(myPicture, 0, 0) 
    startX = 0 
    startY = 0 

    xWidth = width/float(newWidth) 
    yHeight = height/float(newHeight) 


    for x in range(startX, newWidth): 
    for y in range(startY, newHeight): 
     smallPix = getPixel(newPicture, x, y) 

     pixelX = x*xWidth; 
     pixelY = y*yHeight; 


     oPixel = getPixel(myPicture, int(pixelX), int(pixelY)) 
     setColor(smallPix, getColor(oPixel)) 

前述のように、これはイメージを25 x 25に単純にスケーリングしますが、クワイエットゾーンは削除しません。誰かがこの静かなゾーンの削除を実装する方法を教えてもらえますか?ありがとう。

答えて

2
def findQuietZone(pic): 
    width = getWidth(pic) 
    height = getHeight(pic) 

    for x in range(0, width): 
     for y in range(0, height): 
     px = getPixel(pic, x, y) 
     color = getColor(px) 
     if (colour != white): 
      value = getX(px) 

    quietZone = width - value 
関連する問題