Openholo  v4.0
Open Source Digital Holographic Library
ImgCodecDefine.h
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install, copy or use the software.
7 //
8 //
9 // License Agreement
10 // For Open Source Digital Holographic Library
11 //
12 // Openholo library is free software;
13 // you can redistribute it and/or modify it under the terms of the BSD 2-Clause license.
14 //
15 // Copyright (C) 2017-2024, Korea Electronics Technology Institute. All rights reserved.
16 // E-mail : contact.openholo@gmail.com
17 // Web : http://www.openholo.org
18 //
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
21 //
22 // 1. Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
24 //
25 // 2. Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other materials provided with the distribution.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the copyright holder or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 // This software contains opensource software released under GNU Generic Public License,
41 // NVDIA Software License Agreement, or CUDA supplement to Software License Agreement.
42 // Check whether software you use contains licensed software.
43 //
44 //M*/
45 
46 #ifndef __DefineImgCodec_h
47 #define __DefineImgCodec_h
48 
49 
50 namespace oph
51 {
52 
53 #define FMT_SIGN_OHC "OH" // File Format Signature : 0x484F
54 #define LINK_IMG_PATH_SIZE 4*1024*sizeof(BYTE) // 4KB
55 
56  /************************ Enumerator Class for OHC *****************************/
57 
58  /* Unit of Length */
59  enum class LenUnit : uint8_t {
60  Null = 0, /* Null Data */
61  m = 1, /* Meter */
62  cm = 2, /* Centi Meter */
63  mm = 3, /* Milli Meter */
64  um = 4, /* Micro Meter */
65  nm = 5, /* Nano Meter */
66  };
67 
68  /* Color Channel Type */
69  enum class ColorType : uint8_t {
70  Null = 0, /* Null Data */
71  RGB = 1, /* RGB 3-channel */
72  MLT = 2, /* Multiple Colors : Grayscale color is the one case of MLT. */
73  //GRY = 3, /* Grayscale 1-channel */
74  };
75 
76  /* Color Arrangement */
77  enum class ColorArran : uint8_t {
78  Null = 0, /* Null Data */
79  SeqtChanl = 1, /* Sequential RGB Color channels */
80  EachChanl = 2, /* Each Color channels */
81  };
82 
83  /* Complex Field Data Type */
84  enum class DataType : uint8_t {
85  Null = 0, /* Null Data */
86  Int8 = 1, /* char */
87  Int16 = 2, /* short */
88  Int32 = 3, /* long */
89  Int64 = 4, /* longlong */
90  Uint8 = 5, /* uchar */
91  Uint16 = 6, /* ushort */
92  Uint32 = 7, /* ulong */
93  Uint64 = 8, /* ulonglong */
94  Float32 = 9, /* Single precision floating */
95  Float64 = 10, /* Double precision floating */
96  CmprFmt = 11, /* Compressed Image File */
97  };
98 
99  /* Field Store Type */
100  enum class FldStore : uint8_t {
101  Null = 0, /* Null Data */
102  Directly = 1, /* Field data is directly stored at the 'Field Data' region. */
103  LinkFile = 2, /* Field data is stored at separate files and they are referred by path. 'Field Data' region stores those file paths. */
104  };
105 
106  /* Encoding Type of Field Data Domain */
107  enum class FldCodeType : uint8_t {
108  Null = 0, /* Null Data */
109  AP = 1, /* Amplitude & Phase */
110  RI = 2, /* Real & Imaginary */
111  AE = 3, /* Amplitude-only Encoded */
112  PE = 4, /* Phase-only Encoded */
113  };
114 
115  /* Phase Encoded Type : Boolean */
116  enum class BPhaseCode : uint8_t {
117  Null = 0,
118  NotEncoded = 0,
119  Encoded = 1,
120  };
121 
122  /* Compressed Image Type File Format */
123  enum class CompresType : uint8_t {
124  Null = 0, /* No Image Format, Directly store raw data. */
125  BMP = 1, /* Bitmap (bmp, dib) */
126  JPG = 2, /* JPEG (jpg, jpeg, jpe) */
127  J2K = 3, /* JPEG-2000 (jpf, jpx, jp2, j2c, j2k, jpc) */
128  PNG = 4, /* PNG (png, pns) */
129  GIF = 5, /* GIF (gif) */
130  TIF = 6, /* TIFF (tif, tiff) */
131  };
132 
133 
134  /************************ File Header Struct for OHC *****************************/
135  /* Openholo Complex Field File Format(*.ohc) Definition */
136 #pragma pack(push, 1)
137  struct ohcFileHeader {
138  int8_t fileSignature[2]; /* File Type(2 Byte) : 'OH' 0x484F */
139  uint64_t fileSize; /* Entire file size(in byte) */
140  uint8_t fileVersionMajor; /* Major version of file format */
141  uint8_t fileVersionMinor; /* Minor version of file format */
142  uint32_t fileReserved1; /* For potential use. Currently zero. */
143  uint32_t fileReserved2; /* For potential use. Currently zero. */
144  uint32_t fileOffBytes; /* Address of complex field data */
145 
146  //basic constructor
148  this->fileSignature[0] = FMT_SIGN_OHC[0];
149  this->fileSignature[1] = FMT_SIGN_OHC[1];
150  this->fileSize = 0;
151  this->fileVersionMajor = _OPH_LIB_VERSION_MAJOR_;
152  this->fileVersionMinor = _OPH_LIB_VERSION_MINOR_;
153  this->fileReserved1 = 0;
154  this->fileReserved2 = 0;
155  this->fileOffBytes = 0;
156  }
157  };
158 
160  uint32_t headerSize; /* Size of Field Info Header(in byte) : InfoHeader + WaveLengthTable */
161  uint32_t pxNumX; /* Number of pixels of field data in x-direction */
162  uint32_t pxNumY; /* Number of pixels of field data in y-direction */
163  double_t pxPitchX; /* Pixel pitch of field data in x-direction */
164  double_t pxPitchY; /* Pixel pitch of field data in y-direction */
165  LenUnit pitchUnit; /* Unit of pixel pitch */
166  uint32_t wavlenNum; /* Number of Wavelengths */
167  ColorType clrType; /* Color Type */
168  ColorArran clrArrange; /* Color arrangement */
169  LenUnit wavlenUnit; /* Unit of Wavelength (in Wavelength Table). */
170  DataType cmplxFldType; /* Complex Field Data Type. */
171  FldStore fldStore; /* Field Store Type. */
172  FldCodeType fldCodeType; /* Field Encoding Type. */
173  BPhaseCode bPhaseCode; /* Phase Encoded Type(Boolean). 0: Not Encoded, 1: Encoded */
174  double_t phaseCodeMin; /* Phase Encoded Min. */
175  double_t phaseCodeMax; /* Phase Encoded Max. */
176  uint64_t fldSize; /* Entire Field data size */
177  CompresType comprsType; /* Image file format of complex data : for 'cmplxFldType == ImgFmt' */
178 
179  //basic constructor
181  this->headerSize = 0;
182  this->pxNumX = (uint32_t)-1;
183  this->pxNumY = (uint32_t)-1;
184  this->pxPitchX = (double_t)-1;
185  this->pxPitchY = (double_t)-1;
186  this->pitchUnit = LenUnit::Null;
187  this->wavlenNum = 0;
188  this->clrType = ColorType::Null;
189  this->clrArrange = ColorArran::Null;
190  this->wavlenUnit = LenUnit::Null;
191  this->cmplxFldType = DataType::Null;
192  this->fldStore = FldStore::Null;
193  this->fldCodeType = FldCodeType::Null;
194  this->bPhaseCode = BPhaseCode::Null;
195  this->phaseCodeMin = -1.0;
196  this->phaseCodeMax = 1.0;
197  this->fldSize = 0;
198  this->comprsType = CompresType::Null;
199  }
200  };
201 #pragma pack(pop)
202  struct ohcHeader {
205  std::vector<double_t> wavlenTable; /* Wavelength : Scalable Data Size(8/24/8n). When 'clrType' is RGB, wavelengths of red, green, and blue are stored sequentially; When 'clrType' is MLT, size of this field is 8*n bytes, where 'n' is the 'wavlenNum'. */
206  };
207 }
208 
209 #endif
ohcFieldInfoHeader fieldInfo
#define _OPH_LIB_VERSION_MAJOR_
Definition: include.h:49
#define FMT_SIGN_OHC
std::vector< double_t > wavlenTable
ohcFileHeader fileHeader
#define _OPH_LIB_VERSION_MINOR_
Definition: include.h:50
Definition: Bitmap.h:49