You can think of fish-eye "undistortion" as a two-step process:
1) from the distorted image, use the rho function from the ocam calib toolbox to recover the angle at which the light rays entered the lens
2) pick a calibration matrix of your liking to do the pinhole camera perspective projection and obtain an undistorted image.
The OCamCalib toolbox does step 1) for you, but what K-matrix you pick in step 2) is up to you. You can pick focal length, resolution etc however you please.
That said, there are a couple of convenient choices:
- pick K such that all (or almost all) pixels of the perspective image fit into the undistorted image.
- pick K such that the undistorted image is cropped in a way that it has no "empty pixels".
Attached is matlab code that will help you with the undistortion. The functions have documentation, please read.You first need to run ocam_undistort_map(). This will give you a structure back that has a member ".K" containing the perspective matrix, and a precomputed index for undistortion. This map has to be precomputed only once for a given camera model. Use it then as an argument to ocam_undistort().
Good luck.