Magick++ 7.1.1
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 (sscanf(hash_.substr(i*5,5).c_str(),"%05x",&hex) != 1)
157 throw ErrorOption("Invalid hash value");
158
159 value=((unsigned short)hex) / pow(10.0, (double)(hex >> 17));
160 if (hex & (1 << 16))
161 value=-value;
162 if (i < 7)
163 _srgbHuPhash[i]=value;
164 else
165 _hclpHuPhash[i-7]=value;
166 }
167}

◆ ~ChannelPerceptualHash()

Magick::ChannelPerceptualHash::~ChannelPerceptualHash ( void  )

Definition at line 169 of file Statistic.cpp.

170{
171}

◆ ChannelPerceptualHash() [4/4]

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

Definition at line 263 of file Statistic.cpp.

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

Member Function Documentation

◆ channel()

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

Definition at line 217 of file Statistic.cpp.

218{
219 return(_channel);
220}

◆ hclpHuPhash()

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

Definition at line 255 of file Statistic.cpp.

256{
257 if (index_ > 6)
258 throw ErrorOption("Valid range for index is 0-6");
259
260 return(_hclpHuPhash.at(index_));
261}

◆ isValid()

bool Magick::ChannelPerceptualHash::isValid ( ) const

Definition at line 222 of file Statistic.cpp.

223{
224 return(_channel != SyncPixelChannel);
225}

◆ operator std::string()

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

Definition at line 173 of file Statistic.cpp.

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

◆ srgbHuPhash()

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

Definition at line 247 of file Statistic.cpp.

248{
249 if (index_ > 6)
250 throw ErrorOption("Valid range for index is 0-6");
251
252 return(_srgbHuPhash.at(index_));
253}

◆ sumSquaredDifferences()

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

Definition at line 227 of file Statistic.cpp.

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

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: