Magick___lib_libMagick___@MAGICK_MAJOR_VERSION@_@MAGICK_ABI_SUFFIX@_la_SOURCES = \
Magick++/lib/Blob.cpp \
Magick++/lib/BlobRef.cpp \
+ Magick++/lib/ChannelMoments.cpp \
Magick++/lib/CoderInfo.cpp \
Magick++/lib/Color.cpp \
Magick++/lib/Drawable.cpp \
Magick++/lib/Magick++.h \
Magick++/lib/Magick++/Blob.h \
Magick++/lib/Magick++/BlobRef.h \
+ Magick++/lib/Magick++/ChannelMoments.h \
Magick++/lib/Magick++/CoderInfo.h \
Magick++/lib/Magick++/Color.h \
Magick++/lib/Magick++/Drawable.h \
MAGICKPP_INCHEADERS_OPT = \
Magick++/lib/Magick++/Blob.h \
+ Magick++/lib/Magick++/ChannelMoments.h \
Magick++/lib/Magick++/CoderInfo.h \
Magick++/lib/Magick++/Color.h \
Magick++/lib/Magick++/Drawable.h \
--- /dev/null
+// This may look like C code, but it is really -*- C++ -*-
+//
+// Copyright Dirk Lemstra, 2014
+//
+// Implementation of channel moments.
+//
+
+#define MAGICKCORE_IMPLEMENTATION 1
+#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
+
+#include "Magick++/Include.h"
+#include "Magick++/ChannelMoments.h"
+
+using namespace std;
+
+Magick::ChannelMoments::ChannelMoments(void)
+ : _huInvariants(),
+ _centroidX(0.0),
+ _centroidY(0.0),
+ _ellipseAxisX(0.0),
+ _ellipseAxisY(0.0),
+ _ellipseAngle(0.0),
+ _ellipseEccentricity(0.0),
+ _ellipseIntensity(0.0)
+{
+}
+
+Magick::ChannelMoments::ChannelMoments(const ChannelMoments &channelMoments_)
+ : _huInvariants(channelMoments_._huInvariants),
+ _centroidX(channelMoments_._centroidX),
+ _centroidY(channelMoments_._centroidY),
+ _ellipseAxisX(channelMoments_._ellipseAxisX),
+ _ellipseAxisY(channelMoments_._ellipseAxisY),
+ _ellipseAngle(channelMoments_._ellipseAngle),
+ _ellipseEccentricity(channelMoments_._ellipseEccentricity),
+ _ellipseIntensity(channelMoments_._ellipseIntensity)
+{
+//channelMoments_
+}
+
+Magick::ChannelMoments::~ChannelMoments(void)
+{
+}
+
+Magick::ChannelMoments::ChannelMoments(
+ const MagickCore::ChannelMoments *channelMoments_)
+ : _huInvariants(),
+ _centroidX(channelMoments_->centroid.x),
+ _centroidY(channelMoments_->centroid.y),
+ _ellipseAxisX(channelMoments_->ellipse_axis.x),
+ _ellipseAxisY(channelMoments_->ellipse_axis.y),
+ _ellipseAngle(channelMoments_->ellipse_angle),
+ _ellipseEccentricity(channelMoments_->ellipse_eccentricity),
+ _ellipseIntensity(channelMoments_->ellipse_intensity)
+{
+ size_t
+ i;
+
+ for (i=0; i<8; i++)
+ _huInvariants.push_back(channelMoments_->I[i]);
+}
+
+double Magick::ChannelMoments::centroidX(void) const
+{
+ return(_centroidX);
+}
+
+double Magick::ChannelMoments::centroidY(void) const
+{
+ return(_centroidY);
+}
+
+double Magick::ChannelMoments::ellipseAxisX(void) const
+{
+ return(_ellipseAxisX);
+}
+
+double Magick::ChannelMoments::ellipseAxisY(void) const
+{
+ return(_ellipseAxisY);
+}
+
+double Magick::ChannelMoments::ellipseAngle(void) const
+{
+ return(_ellipseAngle);
+}
+
+double Magick::ChannelMoments::ellipseEccentricity(void) const
+{
+ return(_ellipseEccentricity);
+}
+
+double Magick::ChannelMoments::ellipseIntensity(void) const
+{
+ return(_ellipseIntensity);
+}
+
+double Magick::ChannelMoments::huInvariants(const size_t index_) const
+{
+ if (index_ > 7)
+ throw std::out_of_range("Valid range for index is 0-7");
+
+ return(_huInvariants.at(index_));
+}
\ No newline at end of file
ThrowPPException;
}
+Magick::ChannelMoments Magick::Image::moments(void)
+{
+ ChannelMoments
+ channelMoments;
+
+ MagickCore::ChannelMoments*
+ channel_moments;
+
+ GetPPException;
+ channel_moments=GetImageMoments(constImage(),&exceptionInfo);
+ if (channel_moments != (MagickCore::ChannelMoments *) NULL)
+ {
+ channelMoments=ChannelMoments(channel_moments);
+ channel_moments=(MagickCore::ChannelMoments *) RelinquishMagickMemory(
+ channel_moments);
+ }
+ ThrowPPException;
+ return(channelMoments);
+}
+
void Magick::Image::morphology(const MorphologyMethod method_,
const std::string kernel_,const ssize_t iterations_)
{
--- /dev/null
+// This may look like C code, but it is really -*- C++ -*-
+//
+// Copyright Dirk Lemstra, 2014
+//
+// Definition of channel moments.
+//
+
+#if !defined (Magick_ChannelMoments_header)
+#define Magick_ChannelMoments_header
+
+#include "Magick++/Include.h"
+#include <vector>
+
+namespace Magick
+{
+ class MagickPPExport ChannelMoments
+ {
+ public:
+
+ // Default constructor
+ ChannelMoments(void);
+
+ // Copy constructor
+ ChannelMoments(const ChannelMoments &channelMoments_);
+
+ // Destroy channel moments
+ ~ChannelMoments(void);
+
+ //
+ // Implemementation methods
+ //
+ ChannelMoments(const MagickCore::ChannelMoments *channelMoments_);
+
+ // X position of centroid
+ double centroidX(void) const;
+
+ // Y position of centroid
+ double centroidY(void) const;
+
+ // X position of ellipse axis
+ double ellipseAxisX(void) const;
+
+ // Y position of ellipse axis
+ double ellipseAxisY(void) const;
+
+ // Ellipse angle
+ double ellipseAngle(void) const;
+
+ // Ellipse eccentricity
+ double ellipseEccentricity(void) const;
+
+ // Ellipse intensity
+ double ellipseIntensity(void) const;
+
+ // Hu invariants (valid range for index is 0-7)
+ double huInvariants(const size_t index_) const;
+
+ private:
+ std::vector<double> _huInvariants;
+ double _centroidX;
+ double _centroidY;
+ double _ellipseAxisX;
+ double _ellipseAxisY;
+ double _ellipseAngle;
+ double _ellipseEccentricity;
+ double _ellipseIntensity;
+ };
+
+}
+
+#endif // Magick_ChannelMoments_header
\ No newline at end of file
#include <string>
#include <list>
#include "Magick++/Blob.h"
+#include "Magick++/ChannelMoments.h"
#include "Magick++/Color.h"
#include "Magick++/Drawable.h"
#include "Magick++/Exception.h"
void modulate(const double brightness_,const double saturation_,
const double hue_);
+ // Returns the normalized moments of one or more image channels.
+ ChannelMoments moments(void);
+
// Applies a kernel to the image according to the given mophology method.
void morphology(const MorphologyMethod method_,const std::string kernel_,
const ssize_t iterations_=1);
using MagickCore::GetExceptionInfo;
using MagickCore::GetGeometry;
using MagickCore::GetImageArtifact;
+ using MagickCore::GetImageMoments;
using MagickCore::GetImageBoundingBox;
using MagickCore::GetImageDistortion;
using MagickCore::GetImageDepth;