⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lvlut.h

📁 相机传输图像程序源代码 拜耳模式(RAW格式文件)与RGB图像数据互相转换函数库
💻 H
字号:

#ifndef ___LVLUT
#define ___LVLUT


#include <roi.h>
#include <lvpackon.h>

/** Type of the LUT. */
typedef enum _eLvLUTType {
    LvLUT_Invalid=-1,   /**< Invalid LUT or no LUT is set. */
    LvLUT_Mono8,        /**< 8bit mono LUT type. */
    LvLUT_Mono10,       /**< 10bit mono LUT type. */
    LvLUT_Mono12,       /**< 12bit mono LUT type. */
    LvLUT_RGB,          /**< 24bit RGB LUT type. */
    LvLUT_Bayer,        /**< Bayer LUT type - 24bit. */
    LvLUT_Gamma,
    LvLUT_Last
    } LvLUTType;

/** Components of the LUT. */
typedef enum _eLvLUTComponent {
    LvLUTCmp_All,                 /**< Operation with all components of the LUT (Red, Green and Blue). */
    LvLUTCmp_Mono=LvLUTCmp_All,   /**< When using LUTType mono, then with all==one component will be operated. */ 
    LvLUTCmp_Red,                 /**< Operation with Red component of the LUT. */
    LvLUTCmp_Green,               /**< Operation with Green component of the LUT. */
    LvLUTCmp_Blue,                /**< Operation with Blue component of the LUT. */
    LvLUTCmp_Last
    } LvLUTComponent;

#define LvLutGammaFactor 10000


/** Look up table data structure.
 * The look up table ("LUT") can be applied to the input data, changing each pixel value using a
 * simple lookup: every possible input value is assigned to a corresponding output value
 * through the table. It is an exception among the preprocessing functions available for the
 * frame grabbers.
 */
typedef struct _tagLvLUTData {
    /** Type of LUT.
     * Use one of the LvLUTType enumeration.
     * @sa LvLUTType
     */
    U32BIT Type;
    /** LUT union. */
    union {
        /** Structure for mono, 8bit LUT. */
        struct {
            U8BIT M[256];    /**< Single component of mono 8bit, size 256B. */
            } Mono8;
        /** Structure for RGB, 24bit LUT. */
        struct {
            U8BIT R[256];    /**< Red component, size 256B. */
            U8BIT G[256];    /**< Green component, size 256B. */
            U8BIT B[256];    /**< Blue component, size 256B. */
            } RGB;
        struct {
            U8BIT R[256];    /**< Red component, size 256B. */
            U8BIT G[256];    /**< Green component, size 256B. */
            U8BIT B[256];    /**< Blue component, size 256B. */
            } Bayer;
        /** Structure for mono, 10bit LUT. */
        struct {
            U16BIT M[1024];  /**< Single component of mono 10bit, size 1024*2B (2048B). */
            } Mono10;
        /** Structure for mono, 12bit LUT. */
        struct {
            U16BIT M[4096];  /**< Single component of mono 12bit, size 4096*2B (8192B). */
            } Mono12;
        struct {
            U32BIT Value;
            } Gamma;
        } LUT;
    /** Level union.
     * Used to set low and high limits of the each type of LUT. 
     */
    union {
        /** Low and high limits of the 8bit Mono LUT type. */
        struct {
            U16BIT MHigh;    /**< The highest possible value of the LUT type Mono 8bit. */
            U16BIT MLow;     /**< The lowest possible value of the LUT type Mono 8bit. */
            } Mono8;
        /** Low and high limits of the RGB 24bit LUT type. */
        struct {
            U16BIT RHigh;    /**< The highest possible value of red component of the LUT type RGB. */
            U16BIT RLow;     /**< The lowest possible value of red component of the LUT type RGB. */
            U16BIT GHigh;    /**< The highest possible value of green component of the LUT type RGB. */
            U16BIT GLow;     /**< The lowest possible value of green component of the LUT type RGB. */
            U16BIT BHigh;    /**< The highest possible value of blue component of the LUT type RGB. */
            U16BIT BLow;     /**< The lowest possible value of blue component of the LUT type RGB. */
            } RGB;
        /**  Low and high limits of the Bayer 24bit LUT type. */
        struct {
            U16BIT RHigh;    /**< The highest possible value of the red component of the Bayer LUT. */
            U16BIT RLow;     /**< The lowest possible value of the red component of the Bayer LUT. */
            U16BIT GHigh;    /**< The highest possible value of the green component of the Bayer LUT. */
            U16BIT GLow;     /**< The lowest possible value of the green component of the Bayer LUT. */
            U16BIT BHigh;    /**< The highest possible value of the blue component of the Bayer LUT. */
            U16BIT BLow;     /**< The lowest possible value of the blue component of the Bayer LUT. */
            } Bayer;
        /** Low and high limits of the 10bit mono LUT type. */
        struct {
            U16BIT MHigh;    /**< The highest possible value of the LUT type Mono 10bit. */
            U16BIT MLow;     /**< The lowest possible value of the LUT type Mono 10bit. */
            } Mono10;
        /** Low and high limits of the 12bit mono LUT type. */
        struct {
            U16BIT MHigh;    /**< The highest possible value of the LUT type Mono 12bit. */
            U16BIT MLow;     /**< The lowest possible value of the LUT type Mono 12bit. */
            } Mono12;
        } Level;
    } LvLUTData;


/** LvLUT class.
 * This class is derived from LvLUTData structure and so is simplest to
 * usage then standart LvLUTData structure.
 * This class also implements several methods to fill LvLUTData structure with
 * properly values.
 */
LVDSYCLASS LvLUT : public LvLUTData {
	protected:

    public:
        /** Base constructor of LvLUT class.
         * Due to type of LUT it fills internal LUT with linear data.
         * @param aType Type of LUT. One of the LvLUTType enumeration
         */         
        LvLUT(LvLUTType aType=LvLUT_Mono8);
        
        /** Change actual LUT type to new one.
         * Due to type of LUT it fills internal LUT with linear data.
         * @param aType Type of new LUT. one of the LvLUTType enumeration
         * @return @ref ErrorDefinitions
         */
        LVSTATUS SetType(LvLUTType aType);
        /** Sets the source data to new ones.
         * This function copies all datas from new LUT to this class.
         * @param LUT new LUT
         */
        void SetLUTData(LvLUTData *LUT);

        /** Function fills up internal LUT using linear datas.
         * You can select which component of LUT has to be filled up. See LvLUTComponent enumeration for 
         * possibilities.
         * @param Comp Which component has to be filled up with linear datas
         * @return @ref ErrorDefinitions
         */
        LVSTATUS Linear(LvLUTComponent Comp=LvLUTCmp_All);

        LVSTATUS Gamma(float gamma, LvLUTComponent Comp=LvLUTCmp_All);
        
        /** Scale LUT components by your factor.
         * Use this function to scale up/down current LUT.
         * @param Scale Factor to scaling
         * @param Comp Which component has to be scalled. Select one from LvLUTComponent enumeration
         * @return @ref ErrorDefinitions
         */
        LVSTATUS Scale(float Scale, LvLUTComponent Comp=LvLUTCmp_All); // Pix=Pix*Scale
        // ...and so on

        /** Corrects black level of image.
         * Use this function when your images from camera is too light. Set camera view to see the darkest color of
         * average view and snap this image. Then pass this image to this function, when you use this LUT on the avarage
         * image then your images will be darker and more corespondent.
         * @param BlackImage pointer to image with the darkest color of view (some black color paper in the position which is
         *                   viewed by camera)
         * @param r Not used.
         * @param Comp Not used.
         * @return @ref ErrorDefinitions
         * @sa WhiteCorrection
         */
        LVSTATUS BlackCorrection(LvROI *BlackImage, RECT *r=NULL, LvLUTComponent Comp=LvLUTCmp_All);
        
        /** Corrects white level of image.
         * Use this function when your images from camera is too dark. Set camera view to see the lighest color of average
         * view and snap this image. Then pass this image to this function, when you use this LUT on the average image
         * then your images will be lighter and more correspondent.
         * @param WhiteImage pointer to image with the lightest color of view (some white paper in the position which is
         *                   viewed by camera)
         * @param r Not used.
         * @param Comp Not used.
         * @return @ref ErrorDefinitions
         * @sa BlackCorrection
         */
        LVSTATUS WhiteCorrection(LvROI *WhiteImage, RECT *r=NULL, LvLUTComponent Comp=LvLUTCmp_All);
        
        /** Corrects black and white level of image.
         * See WhiteCorrection() and BlackCorrection() functions, this function calls both of them.
         * @param BlackImage reference to black image
         * @param WhiteImage reference to white image
         * @param r Not used.
         * @param Comp Not used.
         * @return @ref ErrorDefinitions
         * @sa BlackCorrection(), WhiteCorrection()
         */
        LVSTATUS BlackWhiteCorrection(LvROI *BlackImage, LvROI *WhiteImage, RECT *r=NULL, LvLUTComponent Comp=LvLUTCmp_All);
    };

#include <lvpackof.h>


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -