diff --git a/bin/defocus.c b/bin/defocus.c index 4de3679..9bebb00 100644 --- a/bin/defocus.c +++ b/bin/defocus.c @@ -4,12 +4,14 @@ #include int pinhole_fn(int argc, char **argv); +int thin_lense_fn(int argc, char **argv); -static const char *_model_names[] = {"pinhole"}; +static const char *_model_names[] = {"pinhole", "thin_lense"}; typedef int (*model_fn)(int argc, char **argv); static model_fn _model_fns[] = { pinhole_fn, + thin_lense_fn, }; void usage(const char *pname) @@ -121,3 +123,9 @@ int pinhole_fn(int argc, char **argv) return error_code; } + +int thin_lense_fn(int argc, char **argv) +{ + fprintf(stderr, "Not implemented yet"); + return 1; +} \ No newline at end of file diff --git a/include/defocus/defocus.h b/include/defocus/defocus.h index 4c9dcb9..2efba8d 100644 --- a/include/defocus/defocus.h +++ b/include/defocus/defocus.h @@ -6,6 +6,6 @@ */ #include "base.h" #include "image.h" -#include "pinhole.h" +#include "models.h" #endif diff --git a/include/defocus/models.h b/include/defocus/models.h new file mode 100644 index 0000000..26e72af --- /dev/null +++ b/include/defocus/models.h @@ -0,0 +1,40 @@ +#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. + * + * 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.) + */ + +#include "image.h" + +/** @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. + * + * @param in_image input image + * @param focal_length the cameras focal length in millimeters. + * @param orig_z the distance of the input image from the camera. + * @param new_z the distance of the generated output image. + * @param out_image the output image. + */ +void df_pinhole(const df_image *in_image, float focal_length, float orig_z, float new_z, df_image *out_image); + +/** @brief Thin-lense model. + * + * @param in_image input image + * @param focal_length the cameras focal length in millimeters. + * @param aperture the aperture size in millimeters. + * @param orig_z the distnce of the input image from the camera. + * @param out_image the output image. + */ +void df_thin_lense( + const df_image *in_image, float focal_length, float aperture, float orig_z, float new_z, df_image *out_image); + +#endif diff --git a/include/defocus/pinhole.h b/include/defocus/pinhole.h deleted file mode 100644 index 1c378e6..0000000 --- a/include/defocus/pinhole.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef DF_PINHOLE_H -#define DF_PINHOLE_H - -/** @file pinhole.h - * @brief Defocus based on pinhole camera model. - */ - -#include "image.h" - -void df_pinhole(const df_image *in_image, float focal_length, float orig_z, float new_z, df_image *out_image); - -#endif diff --git a/lib/pinhole.c b/lib/pinhole.c index 02a6f7f..af2538d 100644 --- a/lib/pinhole.c +++ b/lib/pinhole.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/lib/thin_lense.c b/lib/thin_lense.c new file mode 100644 index 0000000..1c048b2 --- /dev/null +++ b/lib/thin_lense.c @@ -0,0 +1,6 @@ +#include + +void df_thin_lense( + const df_image *in_image, float focal_length, float aperture, float orig_z, float new_z, df_image *out_image) +{ +} \ No newline at end of file diff --git a/meson.build b/meson.build index 8bbdac9..84f5252 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,7 @@ lib = library('df', 'lib/pinhole.c', 'lib/image.c', 'lib/color.c', + 'lib/thin_lense.c', include_directories: incdir, dependencies: m_dep, version: '0.1.0',