💾 Archived View for republic.circumlunar.space › users › johngodlee › posts › 2018-10-10-lai-fix.gmi captured on 2023-04-19 at 23:52:48. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-04)

-=-=-=-=-=-=-

I made a mistake with cropping fisheye photos to a field of view

DATE: 2018-10-10

AUTHOR: John L. Godlee

In a previous post I created an R function to estimate the radius in pixels of a circle with a view angle of given degrees, for a fisheye lens with an equisolid project. I realised afterwards, after doing some testing that this function didn't work. It was close, but some things didn't work quite right. For instance when I changed the focal length of the lens, nothing in the output of the function changed. Here is the new function, which uses the pixel pitch of the camera sensor:

fov.px <- function(deg_theta, focal_length_mm, pixel_pitch_um){
    require(NISTunits)

    # Convert degrees of theta to radians
    rads_theta <- NISTdegTOradian(deg_theta)

    # Calculate radius of circle drawn by angle of view (rads_theta and max_rads_theta) in mm projected onto the sensor plane
    R <-  2 * focal_length_mm * sin(rads_theta / 2)

    # Calculate the px per mm on the sensor, i.e. the pixel pitch
    sensor_px_per_mm_flat <- 1/pixel_pitch_um * 1000

    # Multiply the mm radius of the desired circle by the number of pixels per mm on the sensor, to get the number of pixels radius of the desired circle
    pixels_for_theta <- R * sensor_px_per_mm_flat

    # Print result
    print(paste("Radius of circle:", round(pixels_for_theta, digits = 0), "px"))
}

Similarly, I made a function which can calculate the theta (degrees of radius) of a circle of a given proportional circular crop of the original circle:

fov.theta <- function(prop_crop, full_circle_radius_px, focal_length_mm, pixel_pitch_um){
    require(NISTunits)

    # Calculate the number of pixels in the radius of the crop
    px_crop <- full_circle_radius_px * prop_crop

    # Calculate the radius of the
    theta <- 2 * asin(((pixel_pitch_um * px_crop) / (2 * focal_length_mm * 1000)))

    deg_theta <- NISTradianTOdeg(theta)

    print(paste("Angle of view: ", round(deg_theta, digits = 2), "°", sep = ""))
}