Magick++ 7.1.2
Loading...
Searching...
No Matches
Magick::ChannelPerceptualHash Class Reference
Collaboration diagram for Magick::ChannelPerceptualHash:

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.

122 : _channel(SyncPixelChannel),
123 _srgbHuPhash(7),
124 _hclpHuPhash(7)
125{
126}

◆ ChannelPerceptualHash() [2/4]

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

Definition at line 128 of file Statistic.cpp.

130 : _channel(channelPerceptualHash_._channel),
131 _srgbHuPhash(channelPerceptualHash_._srgbHuPhash),
132 _hclpHuPhash(channelPerceptualHash_._hclpHuPhash)
133{
134}

◆ ChannelPerceptualHash() [3/4]

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

Definition at line 136 of file Statistic.cpp.

138 : _channel(channel_),
139 _srgbHuPhash(7),
140 _hclpHuPhash(7)
141{
142 size_t
143 i;
144
145 if (hash_.length() != 70)
146 throw ErrorOption("Invalid hash length");
147
148 for (i=0; i<14; i++)
149 {
150 unsigned int
151 hex;
152
153 double
154 value;
155
156#if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__)
157 if (sscanf_s(hash_.substr(i*5,5).c_str(),"%05x",&hex) != 1)
158#else
159 if (sscanf(hash_.substr(i*5,5).c_str(),"%05x",&hex) != 1)
160#endif
161 throw ErrorOption("Invalid hash value");
162
163 value=((unsigned short)hex) / pow(10.0, (double)(hex >> 17));
164 if (hex & (1 << 16))
165 value=-value;
166 if (i < 7)
167 _srgbHuPhash[i]=value;
168 else
169 _hclpHuPhash[i-7]=value;
170 }
171}

◆ ~ChannelPerceptualHash()

Magick::ChannelPerceptualHash::~ChannelPerceptualHash ( void )

Definition at line 173 of file Statistic.cpp.

174{
175}

◆ ChannelPerceptualHash() [4/4]

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

Definition at line 267 of file Statistic.cpp.

270 : _channel(channel_),
271 _srgbHuPhash(7),
272 _hclpHuPhash(7)
273{
274 size_t
275 i;
276
277 for (i=0; i<7; i++)
278 {
279 _srgbHuPhash[i]=channelPerceptualHash_->phash[0][i];
280 _hclpHuPhash[i]=channelPerceptualHash_->phash[1][i];
281 }
282}

Member Function Documentation

◆ channel()

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

Definition at line 221 of file Statistic.cpp.

222{
223 return(_channel);
224}

◆ hclpHuPhash()

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

Definition at line 259 of file Statistic.cpp.

260{
261 if (index_ > 6)
262 throw ErrorOption("Valid range for index is 0-6");
263
264 return(_hclpHuPhash.at(index_));
265}

◆ isValid()

bool Magick::ChannelPerceptualHash::isValid ( ) const

Definition at line 226 of file Statistic.cpp.

227{
228 return(_channel != SyncPixelChannel);
229}

◆ operator std::string()

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

Definition at line 177 of file Statistic.cpp.

178{
179 std::string
180 hash;
181
182 size_t
183 i;
184
185 if (!isValid())
186 return(std::string());
187
188 for (i=0; i<14; i++)
189 {
190 char
191 buffer[6];
192
193 double
194 value;
195
196 unsigned int
197 hex;
198
199 if (i < 7)
200 value=_srgbHuPhash[i];
201 else
202 value=_hclpHuPhash[i-7];
203
204 hex=0;
205 while(hex < 7 && fabs(value*10) < 65536)
206 {
207 value=value*10;
208 hex++;
209 }
210
211 hex=(hex<<1);
212 if (value < 0.0)
213 hex|=1;
214 hex=(hex<<16)+(unsigned int)(value < 0.0 ? -(value - 0.5) : value + 0.5);
215 (void) FormatLocaleString(buffer,6,"%05x",hex);
216 hash+=std::string(buffer);
217 }
218 return(hash);
219}

◆ srgbHuPhash()

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

Definition at line 251 of file Statistic.cpp.

252{
253 if (index_ > 6)
254 throw ErrorOption("Valid range for index is 0-6");
255
256 return(_srgbHuPhash.at(index_));
257}

◆ sumSquaredDifferences()

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

Definition at line 231 of file Statistic.cpp.

233{
234 double
235 ssd;
236
237 size_t
238 i;
239
240 ssd=0.0;
241 for (i=0; i<7; i++)
242 {
243 ssd+=((_srgbHuPhash[i]-channelPerceptualHash_._srgbHuPhash[i])*
244 (_srgbHuPhash[i]-channelPerceptualHash_._srgbHuPhash[i]));
245 ssd+=((_hclpHuPhash[i]-channelPerceptualHash_._hclpHuPhash[i])*
246 (_hclpHuPhash[i]-channelPerceptualHash_._hclpHuPhash[i]));
247 }
248 return(ssd);
249}

Member Data 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: