Enrollment 28.2.0
Loading...
Searching...
No Matches

Converts image type ImageType::JPG2000. More...

#include <ImageEncoder.h>

Collaboration diagram for Jp2ImageEncoder:

Public Member Functions

 Jp2ImageEncoder ()
 Construct a new Jpeg 2000 Image Encoder object The default compression ratio is 4:1.
void SetCompressionRatio (int ratio)
 Set compression ratio.
int GetCompressionRatio () const
 Provides compression ratio.
bool IsLossy () const
 Check if encoder setup is lossy.
bool IsLossless () const
 Check if encoder setup is lossless.
void Accept (ImageEncoderVisitor &visitor) const final
 Allow visitor to visit concrete type of encoder.
std::vector< uint8_t > Encode (const RawImage &raw) const final
 Saves given RawImage as formatted image.

Static Public Member Functions

static std::shared_ptr< ImageEncoder > Create (ImageType type)
 Create concrete default encoder for given type.

Detailed Description

Converts image type ImageType::JPG2000.

Member Function Documentation

◆ Accept()

void Accept ( ImageEncoderVisitor & visitor) const
inlinefinalvirtual

Allow visitor to visit concrete type of encoder.

Parameters
visitorImageEncoderVisitor to call

Implements ImageEncoder.

◆ Create()

std::shared_ptr< ImageEncoder > Create ( ImageType type)
inlinestaticinherited

Create concrete default encoder for given type.

Parameters
typeImageType
Exceptions
EnrollmentExceptionwhen image type is unknown
Returns
ImageEncoder

References ImageType::BMP, ImageType::IRAW, ImageType::JPG, ImageType::JPG2000, ImageType::PNG, ImageType::TIFF, ImageException::UNKNOWN_IMAGE, ImageType::WEBP, and ImageType::WSQ.

Referenced by Image::Decode(), and ImageFileSaver::Save().

Here is the caller graph for this function:

◆ Encode()

std::vector< uint8_t > Encode ( const RawImage & raw) const
inlinefinalvirtualinherited

Saves given RawImage as formatted image.

Parameters
rawRawImage
Returns
encoded image
Exceptions
ImageExceptionwhen it is not possible to encode image
InvalidImageArgumentExceptionwhen image is empty

Implements ImageEncoder.

◆ GetCompressionRatio()

int GetCompressionRatio ( ) const
inline

Provides compression ratio.

Returns
compression ratio, the value 1 has meaning lossless compression

◆ IsLossless()

bool IsLossless ( ) const
inline

Check if encoder setup is lossless.

Returns
true lossless encoding
false lossy encoding

◆ IsLossy()

bool IsLossy ( ) const
inline

Check if encoder setup is lossy.

Returns
true lossy encoding
false lossless encoding

◆ SetCompressionRatio()

void SetCompressionRatio ( int ratio)
inline

Set compression ratio.

In JPEG2000, the compression ratio is defined as the ratio of the size of the uncompressed, raw image to the size of the compressed image. \( raw\_size = width * height * number\_of\_channels * bit\_depth /8 \) where bit_depth is number of bits in channel (e.g. 8,16). For example, a compression ratio of 20:1 indicates that the compressed image is 1/20th the size of the raw image. Be aware that even if compression ratio is 1 (lossless) the image will not have raw_size because of used compaction.

To get for example half (ratio 2:1) of image size (the encoded lossless size) use formula \( raw\_size / lossless\_encoded\_jp2\_size * 2 \). The size will be closed to half due to additional size of JP2 overhead.

Parameters
ratiospecifies compression ratio ratio:1. It means that image size will be 1/ratio of uncompressed, raw image size. valid range is <1,1000>. The value 1 mean no compression, lossless.
Exceptions
EnrollmentInvalidArgumentExceptionif the bitrate is not in the valid range <1,1000>.

The documentation for this class was generated from the following file: