NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_image_netpbm.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef __BE_IMAGE_NETPBM__
12#define __BE_IMAGE_NETPBM__
13
14#include <stdexcept>
15
17#include <be_image_image.h>
18
19namespace BiometricEvaluation
20{
21 namespace Image
22 {
32 class NetPBM : public Image
33 {
34 public:
35 enum class Kind {
36 ASCIIPortableBitmap = 1, /* P1 */
37 ASCIIPortableGraymap = 2, /* P2 */
38 ASCIIPortablePixmap = 3, /* P3 */
39 BinaryPortableBitmap = 4, /* P4 */
40 BinaryPortableGraymap = 5, /* P5 */
41 BinaryPortablePixmap = 6 /* P6 */
42 };
43
45 const uint8_t *data,
46 const uint64_t size,
47 const std::string &identifier = "",
48 const statusCallback_t &statusCallback =
50
52 const Memory::uint8Array &data,
53 const std::string &identifier = "",
54 const statusCallback_t &statusCallback =
56
57 ~NetPBM() = default;
58
80 const;
81
84 uint8_t depth) const;
85
98 static bool
100 const uint8_t *data,
101 uint64_t size);
102
103 /*
104 * Utility methods for parsing buffers.
105 */
106
124 static void
126 const uint8_t *data,
127 size_t dataSize,
128 size_t &offset);
129
146 static void
148 const uint8_t *data,
149 size_t dataSize,
150 size_t &offset);
151
172 static std::string
174 const uint8_t *data,
175 size_t dataSize,
176 size_t &offset,
177 size_t sizeOfValue = 0);
178
179 /*
180 * Buffer type conversions.
181 */
182
203 static Memory::uint8Array
205 const uint8_t *bitmap,
206 uint64_t bitmapSize,
207 uint32_t width,
208 uint32_t height);
209
239 static Memory::uint8Array
241 const uint8_t *ASCIIBuf,
242 uint64_t ASCIIBufSize,
243 uint32_t width,
244 uint32_t height,
245 uint8_t depth,
246 uint32_t maxColor);
247
268 static Memory::uint8Array
270 const uint8_t *bitmap,
271 uint64_t bitmapSize,
272 uint32_t width,
273 uint32_t height);
274
275 private:
286 void
287 parseHeader();
288
290 uint32_t _maxColorValue;
292 uint64_t _headerLength;
294 Kind _kind;
295 };
296 }
297}
298
301 BE_Image_NetPBM_Kind_EnumToStringMap);
302
303#endif /* __BE_IMAGE_NETPBM__ */
304
BE_FRAMEWORK_ENUMERATION_DECLARATIONS(BiometricEvaluation::Image::NetPBM::Kind, BE_Image_NetPBM_Kind_EnumToStringMap)
Represent attributes common to all images.
static void defaultStatusCallback(const Framework::Status &status)
Default handling of statuses sent from image processing libraries.
std::function< void(const Framework::Status)> statusCallback_t
static void skipLine(const uint8_t *data, size_t dataSize, size_t &offset)
Skip an entire line of input, placing offset at the first character after the newline.
static void skipComment(const uint8_t *data, size_t dataSize, size_t &offset)
Skip a block of comments in input.
static bool isNetPBM(const uint8_t *data, uint64_t size)
Whether or not data is a netpbm image.
static Memory::uint8Array BinaryBitmapTo8Bit(const uint8_t *bitmap, uint64_t bitmapSize, uint32_t width, uint32_t height)
Convert an binary bitmap (1-bit depth) buffer into an 8-bit depth buffer.
NetPBM(const uint8_t *data, const uint64_t size, const std::string &identifier="", const statusCallback_t &statusCallback=Image::defaultStatusCallback)
static Memory::uint8Array ASCIIBitmapTo8Bit(const uint8_t *bitmap, uint64_t bitmapSize, uint32_t width, uint32_t height)
Convert an ASCII bitmap (1-bit depth) buffer into an 8-bit depth buffer.
Memory::uint8Array getRawGrayscaleData(uint8_t depth) const
Accessor for decompressed data in grayscale.
static std::string getNextValue(const uint8_t *data, size_t dataSize, size_t &offset, size_t sizeOfValue=0)
Obtain the next space-separated value from data, beginning at offset.
NetPBM(const Memory::uint8Array &data, const std::string &identifier="", const statusCallback_t &statusCallback=Image::defaultStatusCallback)
static Memory::uint8Array ASCIIPixmapToBinaryPixmap(const uint8_t *ASCIIBuf, uint64_t ASCIIBufSize, uint32_t width, uint32_t height, uint8_t depth, uint32_t maxColor)
Convert an ASCII pixel map buffer into a binary pixel map buffer.
Memory::uint8Array getRawData() const
Accessor for the raw image data.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...