Magick++ 7.1.1
Loading...
Searching...
No Matches
Magick::ImagePerceptualHash Class Reference
Collaboration diagram for Magick::ImagePerceptualHash:

Public Member Functions

 ImagePerceptualHash (const ImagePerceptualHash &imagePerceptualHash_)
 
 ImagePerceptualHash (const std::string &hash_)
 
 operator std::string () const
 
ChannelPerceptualHash channel (const PixelChannel channel_) const
 
bool isValid () const
 
double sumSquaredDifferences (const ImagePerceptualHash &channelPerceptualHash_)
 
 ImagePerceptualHash (const Image &image_)
 

Private Attributes

std::vector< ChannelPerceptualHash_channels
 

Detailed Description

Definition at line 244 of file Statistic.h.

Constructor & Destructor Documentation

◆ ImagePerceptualHash() [1/4]

Magick::ImagePerceptualHash::ImagePerceptualHash ( void  )

Definition at line 481 of file Statistic.cpp.

482 : _channels()
483{
484}

◆ ImagePerceptualHash() [2/4]

Magick::ImagePerceptualHash::ImagePerceptualHash ( const ImagePerceptualHash imagePerceptualHash_)

Definition at line 486 of file Statistic.cpp.

488 : _channels(imagePerceptualHash_._channels)
489{
490}

◆ ImagePerceptualHash() [3/4]

Magick::ImagePerceptualHash::ImagePerceptualHash ( const std::string &  hash_)

Definition at line 492 of file Statistic.cpp.

493 : _channels()
494{
495 if (hash_.length() != 210)
496 throw ErrorOption("Invalid hash length");
497
498 _channels.push_back(Magick::ChannelPerceptualHash(RedPixelChannel,
499 hash_.substr(0, 70)));
500 _channels.push_back(Magick::ChannelPerceptualHash(GreenPixelChannel,
501 hash_.substr(70, 70)));
502 _channels.push_back(Magick::ChannelPerceptualHash(BluePixelChannel,
503 hash_.substr(140, 70)));
504}

◆ ~ImagePerceptualHash()

Magick::ImagePerceptualHash::~ImagePerceptualHash ( void  )

Definition at line 506 of file Statistic.cpp.

507{
508}

◆ ImagePerceptualHash() [4/4]

Magick::ImagePerceptualHash::ImagePerceptualHash ( const Image image_)

Definition at line 571 of file Statistic.cpp.

573 : _channels()
574{
575 MagickCore::ChannelPerceptualHash*
576 channel_perceptual_hash;
577
578 PixelTrait
579 traits;
580
581 GetPPException;
582 channel_perceptual_hash=GetImagePerceptualHash(image_.constImage(),
583 exceptionInfo);
584 if (channel_perceptual_hash != (MagickCore::ChannelPerceptualHash *) NULL)
585 {
586 traits=GetPixelChannelTraits(image_.constImage(),RedPixelChannel);
587 if ((traits & UpdatePixelTrait) != 0)
588 _channels.push_back(Magick::ChannelPerceptualHash(RedPixelChannel,
589 &channel_perceptual_hash[RedPixelChannel]));
590 traits=GetPixelChannelTraits(image_.constImage(),GreenPixelChannel);
591 if ((traits & UpdatePixelTrait) != 0)
592 _channels.push_back(Magick::ChannelPerceptualHash(GreenPixelChannel,
593 &channel_perceptual_hash[GreenPixelChannel]));
594 traits=GetPixelChannelTraits(image_.constImage(),BluePixelChannel);
595 if ((traits & UpdatePixelTrait) != 0)
596 _channels.push_back(Magick::ChannelPerceptualHash(BluePixelChannel,
597 &channel_perceptual_hash[BluePixelChannel]));
598 channel_perceptual_hash=(MagickCore::ChannelPerceptualHash *)
599 RelinquishMagickMemory(channel_perceptual_hash);
600 }
601 ThrowPPException(image_.quiet());
602}

Member Function Documentation

◆ channel()

Magick::ChannelPerceptualHash Magick::ImagePerceptualHash::channel ( const PixelChannel  channel_) const

Definition at line 520 of file Statistic.cpp.

522{
523 for (std::vector<ChannelPerceptualHash>::const_iterator it =
524 _channels.begin(); it != _channels.end(); ++it)
525 {
526 if (it->channel() == channel_)
527 return(*it);
528 }
529 return(ChannelPerceptualHash());
530}

◆ isValid()

bool Magick::ImagePerceptualHash::isValid ( ) const

Definition at line 532 of file Statistic.cpp.

533{
534 if (_channels.size() != 3)
535 return(false);
536
537 if (_channels[0].channel() != RedPixelChannel)
538 return(false);
539
540 if (_channels[1].channel() != GreenPixelChannel)
541 return(false);
542
543 if (_channels[2].channel() != BluePixelChannel)
544 return(false);
545
546 return(true);
547}

◆ operator std::string()

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

Definition at line 510 of file Statistic.cpp.

511{
512 if (!isValid())
513 return(std::string());
514
515 return static_cast<std::string>(_channels[0]) +
516 static_cast<std::string>(_channels[1]) +
517 static_cast<std::string>(_channels[2]);
518}

◆ sumSquaredDifferences()

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

Definition at line 549 of file Statistic.cpp.

551{
552 double
553 ssd;
554
555 size_t
556 i;
557
558 if (!isValid())
559 throw ErrorOption("instance is not valid");
560 if (!channelPerceptualHash_.isValid())
561 throw ErrorOption("channelPerceptualHash_ is not valid");
562
563 ssd=0.0;
564 for (i=0; i<3; i++)
565 {
566 ssd+=_channels[i].sumSquaredDifferences(_channels[i]);
567 }
568 return(ssd);
569}

Member Data Documentation

◆ _channels

std::vector<ChannelPerceptualHash> Magick::ImagePerceptualHash::_channels
private

Definition at line 279 of file Statistic.h.


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