Loading...
Searching...
No Matches
Magick::ChannelPerceptualHash Class Reference

## Public Member Functions

| ChannelPerceptualHash (const ChannelPerceptualHash &channelPerceptualHash_)
| ChannelPerceptualHash (const PixelChannel channel_, const std::string &hash_)
| operator std::string () const
PixelChannel | channel (void) const
bool | isValid () const
double | sumSquaredDifferences (const ChannelPerceptualHash &channelPerceptualHash_)
double | srgbHuPhash (const size_t index_) const
double | hclpHuPhash (const size_t index_) const
| ChannelPerceptualHash (const PixelChannel channel_, const MagickCore::ChannelPerceptualHash *channelPerceptualHash_)

## Private Attributes

PixelChannel | _channel
std::vector< double > | _srgbHuPhash
std::vector< double > | _hclpHuPhash

## Detailed Description

Definition at line 81 of file Statistic.h.

## Constructor & Destructor Documentation

## ChannelPerceptualHash() [1/4]

Magick::ChannelPerceptualHash::ChannelPerceptualHash | ( | void |  | ) |

Definition at line 121 of file Statistic.cpp.

: _channel(SyncPixelChannel),
_srgbHuPhash(7),
_hclpHuPhash(7)
{
}

## ChannelPerceptualHash() [2/4]

Magick::ChannelPerceptualHash::ChannelPerceptualHash | ( | const ChannelPerceptualHash & | channelPerceptualHash_ | ) |

Definition at line 128 of file Statistic.cpp.

: _channel(channelPerceptualHash_._channel),
_srgbHuPhash(channelPerceptualHash_._srgbHuPhash),
_hclpHuPhash(channelPerceptualHash_._hclpHuPhash)
{
}

## ChannelPerceptualHash() [3/4]

Magick::ChannelPerceptualHash::ChannelPerceptualHash | ( | const PixelChannel | channel_,
|  | const std::string & | hash_ )

Definition at line 136 of file Statistic.cpp.

: _channel(channel_),
_srgbHuPhash(7),
_hclpHuPhash(7)
{
size_t
i;
if (hash_.length() != 70)
throw ErrorOption("Invalid hash length");
for (i=0; i<14; i++)
{
unsigned int
hex;
double
value;
#if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__)
if (sscanf_s(hash_.substr(i*5,5).c_str(),"%05x",&hex) != 1)
#else
if (sscanf(hash_.substr(i*5,5).c_str(),"%05x",&hex) != 1)
#endif
throw ErrorOption("Invalid hash value");
value=((unsigned short)hex) / pow(10.0, (double)(hex >> 17));
if (hex & (1 << 16))
value=-value;
if (i < 7)
_srgbHuPhash[i]=value;
else
_hclpHuPhash[i-7]=value;
}
}

## ~ChannelPerceptualHash()

Magick::ChannelPerceptualHash::~ChannelPerceptualHash | ( | void |  | ) |

Definition at line 173 of file Statistic.cpp.

{
}

## ChannelPerceptualHash() [4/4]

Magick::ChannelPerceptualHash::ChannelPerceptualHash | ( | const PixelChannel | channel_,
|  | const MagickCore::ChannelPerceptualHash * | channelPerceptualHash_ )

Definition at line 267 of file Statistic.cpp.

: _channel(channel_),
_srgbHuPhash(7),
_hclpHuPhash(7)
{
size_t
i;
for (i=0; i<7; i++)
{
_srgbHuPhash[i]=channelPerceptualHash_->phash[0][i];
_hclpHuPhash[i]=channelPerceptualHash_->phash[1][i];
}
}

## Member Function Documentation

## channel()

Magick::PixelChannel Magick::ChannelPerceptualHash::channel | ( | void |  | ) | const

Definition at line 221 of file Statistic.cpp.

{
return(_channel);
}

## hclpHuPhash()

double Magick::ChannelPerceptualHash::hclpHuPhash | ( | const size_t | index_ | ) | const

Definition at line 259 of file Statistic.cpp.

{
if (index_ > 6)
throw ErrorOption("Valid range for index is 0-6");
return(_hclpHuPhash.at(index_));
}

## isValid()

bool Magick::ChannelPerceptualHash::isValid | ( |  | ) | const

Definition at line 226 of file Statistic.cpp.

{
return(_channel != SyncPixelChannel);
}

## operator std::string()

Magick::ChannelPerceptualHash::operator std::string | ( |  | ) | const

Definition at line 177 of file Statistic.cpp.

{
std::string
hash;
size_t
i;
if (!isValid())
return(std::string());
for (i=0; i<14; i++)
{
char
buffer[6];
double
value;
unsigned int
hex;
if (i < 7)
value=_srgbHuPhash[i];
else
value=_hclpHuPhash[i-7];
hex=0;
while(hex < 7 && fabs(value*10) < 65536)
{
value=value*10;
hex++;
}
hex=(hex<<1);
if (value < 0.0)
hex|=1;
hex=(hex<<16)+(unsigned int)(value < 0.0 ? -(value - 0.5) : value + 0.5);
(void) FormatLocaleString(buffer,6,"%05x",hex);
hash+=std::string(buffer);
}
return(hash);
}

## srgbHuPhash()

double Magick::ChannelPerceptualHash::srgbHuPhash | ( | const size_t | index_ | ) | const

Definition at line 251 of file Statistic.cpp.

{
if (index_ > 6)
throw ErrorOption("Valid range for index is 0-6");
return(_srgbHuPhash.at(index_));
}

## sumSquaredDifferences()

double Magick::ChannelPerceptualHash::sumSquaredDifferences | ( | const ChannelPerceptualHash & | channelPerceptualHash_ | ) |

Definition at line 231 of file Statistic.cpp.

{
double
ssd;
size_t
i;
ssd=0.0;
for (i=0; i<7; i++)
{
ssd+=((_srgbHuPhash[i]-channelPerceptualHash_._srgbHuPhash[i])*
(_srgbHuPhash[i]-channelPerceptualHash_._srgbHuPhash[i]));
ssd+=((_hclpHuPhash[i]-channelPerceptualHash_._hclpHuPhash[i])*
(_hclpHuPhash[i]-channelPerceptualHash_._hclpHuPhash[i]));
}
return(ssd);
}

## Field Documentation

## _channel

PixelChannel Magick::ChannelPerceptualHash::_channel

private

Definition at line 125 of file Statistic.h.

## _hclpHuPhash

std::vector<double> Magick::ChannelPerceptualHash::_hclpHuPhash

private

Definition at line 127 of file Statistic.h.

## _srgbHuPhash

std::vector<double> Magick::ChannelPerceptualHash::_srgbHuPhash

private

Definition at line 126 of file Statistic.h.

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

- Statistic.h
- Statistic.cpp