| Algorithm A1—Equirectangular to fisheye |
| imequ2fish(path): img = readimg(path) emi_1 = img.crop((img.width/4, 0, 3 * img.width/4, img.height)) emi_2_1 = img.crop((0, 0, img.width/4, img.height)) emi_2_2 = img.crop((3 * img.width/4, 0, img.width, img.height)) emi_2 = emi_2_1 + emi_2_2 fish_1 = equ2fish(emi_1) fish_2 = equ2fish(emi_2) fish_1.save() fish_2.save() Where equ2fish is defined as: equ2fish(img): C = (img.with/2, img.height/2) foreach pixel in img: point = ((pixel.y – C.x)/C.x, (C.y − fishPos.x)/C.y) R = sqrt(point.x * point.x + point.y * point.y); if R <= 1: phi = R * aperture/2 theta = atan2(point.y, point.x) P = (R * sin(phi) * cos(theta), R * cos(phi), R * sin(phi) * sin(theta)) lon = atan2(P.y, P.x) lat = atan2(P.z, sqrt(P.x * P.x + P.y * P.y)) origPos = (lon/PI, 2 * lat/PI) origPixel = (C.x + origPos.x * C.x, C.y – origPos.y * C.y) if origPixel.x < img.height and origPixl.y < img.width: pixel = img(origPixel.x, origPixel.y) |