Python モードで処理を使用して、画像を読み込んで計算を行っています。一般的な考え方は次のとおりです。
def setup():
global maxx, maxy
maxx = 0
maxy = 0
# load the image
global img
img = loadImage("img.jpg");
maxx = img.width
maxy = img.height
def draw():
image(img, 0, 0);
def mousePressed():
calc()
def calc():
height = int(img.height)
width = int(img.width)
print "width: " + `width`
print "height: " + `height`
print "width*height: " + `width*height`
# iterate over the input image
loadPixels()
print "length of pixels array: " + `len(pixels)`
# ... do stuff with the image
1920x1200 程度の小さな画像の場合、「幅 * 高さ」と「ピクセル配列の長さ」は同じです。3025 × 2009 のような大きな画像の場合、ピクセル配列の長さは大幅に短くなります。3025 x 2009 の例では、違いは次のとおりです:
幅*高さ: 6077225 ピクセル配列の長さ: 3944600
何が起こっているのでしょうか?