Having trouble with this particular task (using JES 4.3). The task is to scale down a QR code image using Python to a 25 x 25 image, and to remove the white border (quiet zone) from the image. I have no trouble scaling it down, but the removal of the quiet zone is troubling. I believe it must be done before the scaling itself, and the quiet zone width can vary. Thus it appears that I need to remove each outer layer of pixels one by one until the program detects that its no longer the quiet zone. Quite sure a while loop is required, but have no clue how to implement that effectively. My code so far:
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))
As mentioned, this simply scales the image to 25 x 25 but does not remove the quiet zone. Can someone tell me how to implement this removal of the quiet zone? Thanks.
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