2023-04-19 13:13:08 +02:00
|
|
|
#ifndef DF_MODELS_H
|
|
|
|
#define DF_MODELS_H
|
|
|
|
|
|
|
|
/** @file models.h
|
|
|
|
* @brief Camera models for defocus.
|
|
|
|
*
|
|
|
|
* Camera models are usually implemented as a function taking an input image and parameters required for the model
|
|
|
|
* and produce an output image.
|
|
|
|
*
|
2023-05-08 13:28:53 +02:00
|
|
|
* Parameters are contained in a parameter struct, because this enables us to something similar to named parameters.
|
|
|
|
* We can also do default parameters, by leaving some values set to zero.
|
|
|
|
*
|
|
|
|
* @code{c}
|
|
|
|
* df_thin_lense((df_thin_lense){
|
|
|
|
* .focal_length = 42.f,
|
|
|
|
* .aperture = 21.f,
|
|
|
|
* .focal_distance = 150.f,
|
|
|
|
* .out_distance = 200.f},
|
|
|
|
* in_image,
|
|
|
|
* out_image);
|
|
|
|
* @endcode
|
|
|
|
*
|
2023-04-19 13:13:08 +02:00
|
|
|
* All camera models use the same coordinate space: The camera looks along the positive z-axis in a right-handed
|
|
|
|
* coordinate system. (-> positive y is down, positive x is right.)
|
2023-05-08 13:28:53 +02:00
|
|
|
|
2023-04-19 13:13:08 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "image.h"
|
|
|
|
|
2023-05-08 13:28:53 +02:00
|
|
|
/** Parameters for the pinhole model. */
|
|
|
|
typedef struct df_pinhole_params
|
|
|
|
{
|
|
|
|
float focal_length; /**< the cameras focal length in millimeters. */
|
|
|
|
float orig_z; /**< the distance of the input image from the camera. */
|
|
|
|
float new_z; /**< the distance of the generated output image. */
|
|
|
|
} df_pinhole_params;
|
|
|
|
|
2023-04-19 13:13:08 +02:00
|
|
|
/** @brief Simple pinhole camera model.
|
|
|
|
*
|
|
|
|
* The simplest possible(?) camera model.
|
|
|
|
* This function takes an input image at a known distance from the camera and moves it to a new distance.
|
|
|
|
*
|
2023-05-08 13:28:53 +02:00
|
|
|
* @param params model parameters.
|
|
|
|
* @param in_image input image.
|
2023-04-19 13:13:08 +02:00
|
|
|
* @param out_image the output image.
|
|
|
|
*/
|
2023-05-09 13:04:14 +02:00
|
|
|
DF_API void df_pinhole(df_pinhole_params params, const df_image *in_image, df_image *out_image);
|
2023-05-08 13:28:53 +02:00
|
|
|
|
|
|
|
/** Parameters for the thin lense model.
|
|
|
|
*/
|
|
|
|
typedef struct df_thin_lense_params
|
|
|
|
{
|
|
|
|
/** The cameras focal length in millimeters. */
|
|
|
|
float focal_length;
|
|
|
|
|
|
|
|
/** The aperture size in millimeters */
|
|
|
|
float aperture;
|
|
|
|
|
|
|
|
/** The distance between the plane of focus and the camera lens, in millimeters */
|
|
|
|
float focal_distance;
|
|
|
|
|
|
|
|
/** The distance between the output image and the camera lens, in millimeters */
|
|
|
|
float out_distance;
|
|
|
|
|
|
|
|
/** The number of samples per pixel. Leave at 0 for the default value (64). */
|
|
|
|
int sample_count;
|
|
|
|
} df_thin_lense_params;
|
2023-04-19 13:13:08 +02:00
|
|
|
|
|
|
|
/** @brief Thin-lense model.
|
|
|
|
*
|
2023-05-08 13:28:53 +02:00
|
|
|
* @param params model parameters
|
2023-04-19 13:13:08 +02:00
|
|
|
* @param in_image input image
|
|
|
|
* @param out_image the output image.
|
|
|
|
*/
|
2023-05-09 13:04:14 +02:00
|
|
|
DF_API void df_thin_lense(df_thin_lense_params params, const df_image *in_image, df_image *out_image);
|
2023-04-19 13:13:08 +02:00
|
|
|
|
|
|
|
#endif
|