Splitting spherical/pano image into square "components"

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Post Reply
jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Splitting spherical/pano image into square "components"

Post by jumpjack » 2018-07-16T12:37:08-07:00

I found this script which allows extracting a rectangular image from a fishey image:
Fisheye2Rect

Unfortunately it looks like it uses cartesian coordinates to refer a point in the source spherical picture... which is a circle, so it's a little complicated to figure out which coordinates I need to use to split the original images into 12 rectangular images, as if they where manually shot turning around.

User avatar
fmw42
Posts: 24095
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Splitting spherical/pano image into square "components"

Post by fmw42 » 2018-07-16T12:41:14-07:00

You probably need to use pano2rect. Then cut that resulting image into your 12 pieces. Fisheye2rect is not likely what you want to use.

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Splitting spherical/pano image into square "components"

Post by jumpjack » 2018-07-17T10:58:02-07:00

I guess pano2rect starts from equirectangular images, so I would need both fisheye2pano and pano2rect?

User avatar
fmw42
Posts: 24095
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Splitting spherical/pano image into square "components"

Post by fmw42 » 2018-07-17T12:52:27-07:00

jumpjack wrote:
2018-07-17T10:58:02-07:00
I guess pano2rect starts from equirectangular images, so I would need both fisheye2pano and pano2rect?
No pano2rect starts for a fisheye view and unwraps it into a 360 linear panorama. See the example page. Sorry the name might be misleading.

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Splitting spherical/pano image into square "components"

Post by jumpjack » 2018-07-18T03:33:56-07:00

Ok now I am a bit confused. :shock:

Input images for pano2rect and fisheye2pano scripts (from your pages):
Image

Image

pano2rect output:
Image

fisheye2pano output:
Image

Output looks the same, but first image appears erroneously flipped left-to-right.

Anyway what I need are separate images, so rather than using one of above scripts and manually splitting images, I think I'll use fisheye2rect, which directly provides single images; maybe it is slower, but maybe I can... script the script to repeteadly launch the script to produce all the 12 frames I need.

I have just to setup a converter from polar to rectangular coordinates, put it into a spreadsheet and make it generate needed command lines.

jumpjack
Posts: 61
Joined: 2010-12-10T05:29:16-07:00
Authentication code: 8675308

Re: Splitting spherical/pano image into square "components"

Post by jumpjack » 2018-07-18T06:22:19-07:00

Ok this set of commands, applied to 4 different spherical images created moving around a room (from test01.jpg to test04.jpg) should produce 48 different images, which should allow a 3d reconstruction of the room.
Source images must be spherical images, 235° FOV, 2048x2048.

Code: Select all

./fisheye2rect -i 235 -o 90 -l  2048,1024 800x600 test01.jpg out01.jpg
./fisheye2rect -i 235 -o 90 -l  1911,512 800x600 test01.jpg out02.jpg
./fisheye2rect -i 235 -o 90 -l  1536,137 800x600 test01.jpg out03.jpg
./fisheye2rect -i 235 -o 90 -l  1024,0 800x600 test01.jpg out04.jpg
./fisheye2rect -i 235 -o 90 -l  512,137 800x600 test01.jpg out05.jpg
./fisheye2rect -i 235 -o 90 -l  137,512 800x600 test01.jpg out06.jpg
./fisheye2rect -i 235 -o 90 -l  0,1024 800x600 test01.jpg out07.jpg
./fisheye2rect -i 235 -o 90 -l  137,1536 800x600 test01.jpg out08.jpg
./fisheye2rect -i 235 -o 90 -l  512,1911 800x600 test01.jpg out09.jpg
./fisheye2rect -i 235 -o 90 -l  1024,2048 800x600 test01.jpg out10.jpg
./fisheye2rect -i 235 -o 90 -l  1536,1911 800x600 test01.jpg out11.jpg
./fisheye2rect -i 235 -o 90 -l  1911,1536 800x600 test01.jpg out12.jpg
./fisheye2rect -i 235 -o 90 -l  2048,1024 800x600 test02.jpg out13.jpg
./fisheye2rect -i 235 -o 90 -l  1911,512 800x600 test02.jpg out14.jpg
./fisheye2rect -i 235 -o 90 -l  1536,137 800x600 test02.jpg out15.jpg
./fisheye2rect -i 235 -o 90 -l  1024,0 800x600 test02.jpg out16.jpg
./fisheye2rect -i 235 -o 90 -l  512,137 800x600 test02.jpg out17.jpg
./fisheye2rect -i 235 -o 90 -l  137,512 800x600 test02.jpg out18.jpg
./fisheye2rect -i 235 -o 90 -l  0,1024 800x600 test02.jpg out19.jpg
./fisheye2rect -i 235 -o 90 -l  137,1536 800x600 test02.jpg out20.jpg
./fisheye2rect -i 235 -o 90 -l  512,1911 800x600 test02.jpg out21.jpg
./fisheye2rect -i 235 -o 90 -l  1024,2048 800x600 test02.jpg out22.jpg
./fisheye2rect -i 235 -o 90 -l  1536,1911 800x600 test02.jpg out23.jpg
./fisheye2rect -i 235 -o 90 -l  1911,1536 800x600 test02.jpg out24.jpg
./fisheye2rect -i 235 -o 90 -l  2048,1024 800x600 test03.jpg out25.jpg
./fisheye2rect -i 235 -o 90 -l  1911,512 800x600 test03.jpg out26.jpg
./fisheye2rect -i 235 -o 90 -l  1536,137 800x600 test03.jpg out27.jpg
./fisheye2rect -i 235 -o 90 -l  1024,0 800x600 test03.jpg out28.jpg
./fisheye2rect -i 235 -o 90 -l  512,137 800x600 test03.jpg out29.jpg
./fisheye2rect -i 235 -o 90 -l  137,512 800x600 test03.jpg out30.jpg
./fisheye2rect -i 235 -o 90 -l  0,1024 800x600 test03.jpg out31.jpg
./fisheye2rect -i 235 -o 90 -l  137,1536 800x600 test03.jpg out32.jpg
./fisheye2rect -i 235 -o 90 -l  512,1911 800x600 test03.jpg out33.jpg
./fisheye2rect -i 235 -o 90 -l  1024,2048 800x600 test03.jpg out34.jpg
./fisheye2rect -i 235 -o 90 -l  1536,1911 800x600 test03.jpg out35.jpg
./fisheye2rect -i 235 -o 90 -l  1911,1536 800x600 test03.jpg out36.jpg
./fisheye2rect -i 235 -o 90 -l  2048,1024 800x600 test04.jpg out25.jpg
./fisheye2rect -i 235 -o 90 -l  1911,512 800x600 test04.jpg out26.jpg
./fisheye2rect -i 235 -o 90 -l  1536,137 800x600 test04.jpg out27.jpg
./fisheye2rect -i 235 -o 90 -l  1024,0 800x600 test04.jpg out28.jpg
./fisheye2rect -i 235 -o 90 -l  512,137 800x600 test04.jpg out29.jpg
./fisheye2rect -i 235 -o 90 -l  137,512 800x600 test04.jpg out30.jpg
./fisheye2rect -i 235 -o 90 -l  0,1024 800x600 test04.jpg out31.jpg
./fisheye2rect -i 235 -o 90 -l  137,1536 800x600 test04.jpg out32.jpg
./fisheye2rect -i 235 -o 90 -l  512,1911 800x600 test04.jpg out33.jpg
./fisheye2rect -i 235 -o 90 -l  1024,2048 800x600 test04.jpg out34.jpg
./fisheye2rect -i 235 -o 90 -l  1536,1911 800x600 test04.jpg out35.jpg
./fisheye2rect -i 235 -o 90 -l  1911,1536 800x600 test04.jpg out36.jpg


"Just" 48 images because 50 is the usual limit of accepted images for freeware versions of stereophotogrammetry programs.

Ok, theory is over; now it's just a matter of testing... :)

Post Reply