DeltaDeltaAA AADeltaDelta.1 High Dynamic Range Pixels

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

.1

High Dynamic Range Pixels Christophe Schlick

Laboratoire Bordelais de Recherche en Informatique

T alence,FRANCE

Introduction

1

2

Description

.1High Dynamic Range Pixels3 Implementation

Acknowledgments

4

C Code

hdp.h

/*

**HDP.H:Encoding and Decoding of High Dynamic Range Pixels

*/

/*

**Encoding and Decoding Types

*/

typedef unsigned char byte;

typedeffloat real;/*change to"double"if you work with double precision*/ typedef byte bytecolor[3];

typedef real realcolor[3];

/*

**Encoding and Decoding Tables

*/

extern byte*EncodeLut;

extern real*DecodeLut;

extern real LutScale;

/*

**Encoding and Decoding Functions

*/

extern int init_HDP_encode(real,real,int);

extern int init_HDP_decode(real,real,real);

extern void exit_HDP_encode(void);

extern void exit_HDP_decode(void);

/*

**Encoding and Decoding Macros

*/

#define HDP_ENCODE(RealColor,ByteColor)(\

ByteColor[0]=EncodeLut[(int)(RealColor[0]*LutScale+0.5)],\

ByteColor[1]=EncodeLut[(int)(RealColor[1]*LutScale+0.5)],\

ByteColor[2]=EncodeLut[(int)(RealColor[2]*LutScale+0.5)])

#define HDP_DECODE(ByteColor,RealColor)(\

RealColor[0]=DecodeLut[ByteColor[0]],\

RealColor[1]=DecodeLut[ByteColor[1]],\

RealColor[2]=DecodeLut[ByteColor[2]])

.1High Dynamic Range Pixels5

hdp.c

/*

**HDP.C:Encoding and Decoding of High Dynamic Range Pixels

*/

#include

void*malloc(unsigned int);

#include"hdp.h"

/*

**Encoding and Decoding Look-Up Tables

*/

byte*EncodeLut;

real*DecodeLut;

real LutScale;

/*

**Construction of the Encoding Look-Up Table

**

**Input:

**LoVal=Less significant(ie lowest non zero)value of the incoming range

**HiVal=Most significant(ie highest)value of the incoming range

**NbVal=Number of elements in the encoding LUT

**

**Output:

**The function returns0if the allocation failed

*/

int init_HDP_encode(real LoVal,real HiVal,int NbVal)

{

real t,r;

int n;

EncodeLut=(byte*)malloc(NbVal*sizeof(byte));

if(!EncodeLut)return(NULL);

NbVal--;

/*Scaling factor=ratio between the encoding LUT and the incoming range*/ LutScale=NbVal/HiVal;

/*Bias factor=ratio between the outcoming and the incoming range*/ r=256.0*LoVal/HiVal;

for(n=0;n<=NbVal;n++){

t=(float)n/NbVal;

EncodeLut[n]=255.0*t/(t-r*t+r)+0.5;

}

return(!NULL);

}

相关文档
最新文档