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

📄 gamma.c

📁 用于DSP中的图像矫正.原理是伽马矫正.可以参照灰度与伽马值的对应表
💻 C
字号:
/***************************************************************************/
/*                                                                         */
/*     Experiement3 . C                                                    */
/*                                                                         */
/*     File In/Out and Processing Gamma Calibration                        */
/*                                                                         */
/*     2004/04/05                                                          */
/*                                                                         */
/***************************************************************************/

#include <stdio.h>
#include <math.h>

#define TRUE 1
#define FALSE 0

#define BUFSIZE 4096 /* the buffer size is 64*64=4096 */

/* Global declarations */
int in_buffer[BUFSIZE];       /* processing data buffers */
int out_buffer[BUFSIZE];

/* Functions */
static int gamma(int *input, int *output);
static void dataIO(void);

void main()
{
    int *input = &in_buffer[0];
    int *output = &out_buffer[0];

    puts("the 3rd experiment started\n");

    /* loop forever */
    while(TRUE)
    {       
        /* 
         *  Read input data using a probe-point connected to a host file. 
         *  Write output data to a graph connected through a probe-point.
         */
        // read the input image data.
        dataIO();
        
		puts("processing\n");
        /* Processing Gamma Calibration*/
    	gamma(input, output);
    	
    	// write the output image.
    	// the output file is result.dat.
    	dataIO();
    }
}

/*
 *  ======== processing gamma calibration========
 *
 * FUNCTION: apply gamma calibration to enhance the brightness of dark are in an image.
 *
 * PARAMETERS: address of input and output buffers.
 *
 * RETURN VALUE: TRUE.
 */
 
static int gamma(int *input, int *output)
{
    int i;
    /* the given gamma value is 0.65.*/
    /* please try other gamma values. */
    int LUT[256]={0,  7, 11, 14, 17, 20, 22, 25, 27, 29, 31, 33, 35, 37, 39, 40, 42, 44, 46, 47, 49,
                 50, 52, 53, 55, 56, 58, 59, 61, 62, 63, 65, 66, 68, 69, 70, 71, 73, 74, 75, 76, 78,
                 79, 80, 81, 83, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98,100,101,102,
                103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,
                124,125,126,127,128,129,130,131,131,132,133,134,135,136,137,138,139,140,141,141,142,
                143,144,145,146,147,148,149,149,150,151,152,153,154,155,155,156,157,158,159,160,160,
                161,162,163,164,165,165,166,167,168,169,169,170,171,172,173,173,174,175,176,177,177,
                178,179,180,181,181,182,183,184,185,185,186,187,188,188,189,190,191,191,192,193,194,
                194,195,196,197,197,198,199,200,200,201,202,203,203,204,205,206,206,207,208,208,209,
                210,211,211,212,213,213,214,215,216,216,217,218,218,219,220,221,221,222,223,223,224,
                225,225,226,227,228,228,229,230,230,231,232,232,233,234,234,235,236,236,237,238,238,
                239,240,240,241,242,242,243,244,244,245,246,246,247,248,248,249,250,250,251,252,252,
                253,254,254,255};
    /*replace the brightness with a calibrated value.*/
    for(i=0;i<BUFSIZE;i++){
    	output[i]=LUT[input[i]];
    }
    return(TRUE);
}


/*
 *  ======== dataIO ========
 *
 * FUNCTION: read input signal and write processed output signal.
 *
 * PARAMETERS: none.
 *
 * RETURN VALUE: none.
 */
static void dataIO()
{
    /* do data I/O */
	
    return;
}

⌨️ 快捷键说明

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