Magick++ 7.1.2
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 485 of file Statistic.cpp.

486 : _channels()
487{
488}

◆ ImagePerceptualHash() [2/4]

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

Definition at line 490 of file Statistic.cpp.

492 : _channels(imagePerceptualHash_._channels)
493{
494}

◆ ImagePerceptualHash() [3/4]

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

Definition at line 496 of file Statistic.cpp.

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

◆ ~ImagePerceptualHash()

Magick::ImagePerceptualHash::~ImagePerceptualHash ( void )

Definition at line 510 of file Statistic.cpp.

511{
512}

◆ ImagePerceptualHash() [4/4]

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

Definition at line 575 of file Statistic.cpp.

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

Member Function Documentation

◆ channel()

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

Definition at line 524 of file Statistic.cpp.

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

◆ isValid()

bool Magick::ImagePerceptualHash::isValid ( ) const

Definition at line 536 of file Statistic.cpp.

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

◆ operator std::string()

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

Definition at line 514 of file Statistic.cpp.

515{
516 if (!isValid())
517 return(std::string());
518
519 return static_cast<std::string>(_channels[0]) +
520 static_cast<std::string>(_channels[1]) +
521 static_cast<std::string>(_channels[2]);
522}

◆ sumSquaredDifferences()

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

Definition at line 553 of file Statistic.cpp.

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

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: