ccdpp.cpp

来自「用VC編的數碼相機仿真程序 包括圖像的預處理 DCT變換 壓縮等 最后可用ver」· C++ 代码 · 共 71 行

CPP
71
字号
/*
* Copyright 2008, writen by shikosan
* File name: ccdPP.cpp
* 零偏預處理
*/

#include "ccd.h"
#include "ccdPP.h"

#define SZ_ROW      64
#define SZ_COL      128

// change char into unsigned char by shikosan
// static char buffer[SZ_ROW][SZ_COL];
static unsigned char buffer[SZ_ROW][SZ_COL];

// change unsigned into signed 
// static unsigned rowIndex, colIndex;
static int rowIndex, colIndex;


void CcdppInitialize() 
{
    rowIndex = -1;
    colIndex = -1;
}

// This function performs zero-bias adjustment after each row read in
void CcdppCapture(void) 
{
	// Change char into uchar 
    // char bias;
		unsigned char bias;
    CcdCapture();
    for(rowIndex=0; rowIndex<SZ_ROW; rowIndex++) 
    {
        for(colIndex=0; colIndex<SZ_COL; colIndex++)
        {
           buffer[rowIndex][colIndex] = CcdPopPixel();
        }
        bias = (CcdPopPixel() + CcdPopPixel()) / 2;     
        for(colIndex=0; colIndex<SZ_COL; colIndex++) 
        {
           buffer[rowIndex][colIndex] -= bias;
        }
    }
    rowIndex = 0;
    colIndex = 0;
}

// This function obtains image pixel
// Change char into uchar 
// char CcdppPopPixel(void) 
unsigned char CcdppPopPixel(void) 
{
	// Change char into uchar 
    // char pixel;
	unsigned char pixel;
    pixel = buffer[rowIndex][colIndex];
    if( ++colIndex == SZ_COL ) 
    {
        colIndex = 0;
        if( ++rowIndex == SZ_ROW ) 
        {
            colIndex = -1;
            rowIndex = -1;
        }
    }
    return pixel;
}

⌨️ 快捷键说明

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