8#define MAGICKCORE_IMPLEMENTATION 1
9#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11#include "Magick++/Include.h"
12#include "Magick++/ChannelMoments.h"
13#include "Magick++/Exception.h"
14#include "Magick++/Image.h"
18Magick::ChannelMoments::ChannelMoments(
void)
20 _channel(UndefinedChannel),
26 _ellipseEccentricity(0.0),
27 _ellipseIntensity(0.0)
31Magick::ChannelMoments::ChannelMoments(
const ChannelMoments &channelMoments_)
32 : _huInvariants(channelMoments_._huInvariants),
33 _channel(channelMoments_._channel),
34 _centroidX(channelMoments_._centroidX),
35 _centroidY(channelMoments_._centroidY),
36 _ellipseAxisX(channelMoments_._ellipseAxisX),
37 _ellipseAxisY(channelMoments_._ellipseAxisY),
38 _ellipseAngle(channelMoments_._ellipseAngle),
39 _ellipseEccentricity(channelMoments_._ellipseEccentricity),
40 _ellipseIntensity(channelMoments_._ellipseIntensity)
44Magick::ChannelMoments::~ChannelMoments(
void)
48Magick::ChannelMoments::ChannelMoments(
const ChannelType channel_,
49 const MagickCore::ChannelMoments *channelMoments_)
52 _centroidX(channelMoments_->centroid.x),
53 _centroidY(channelMoments_->centroid.y),
54 _ellipseAxisX(channelMoments_->ellipse_axis.x),
55 _ellipseAxisY(channelMoments_->ellipse_axis.y),
56 _ellipseAngle(channelMoments_->ellipse_angle),
57 _ellipseEccentricity(channelMoments_->ellipse_eccentricity),
58 _ellipseIntensity(channelMoments_->ellipse_intensity)
64 _huInvariants.push_back(channelMoments_->I[i]);
67double Magick::ChannelMoments::centroidX(
void)
const
72double Magick::ChannelMoments::centroidY(
void)
const
77Magick::ChannelType Magick::ChannelMoments::channel(
void)
const
82double Magick::ChannelMoments::ellipseAxisX(
void)
const
84 return(_ellipseAxisX);
87double Magick::ChannelMoments::ellipseAxisY(
void)
const
89 return(_ellipseAxisY);
92double Magick::ChannelMoments::ellipseAngle(
void)
const
94 return(_ellipseAngle);
97double Magick::ChannelMoments::ellipseEccentricity(
void)
const
99 return(_ellipseEccentricity);
102double Magick::ChannelMoments::ellipseIntensity(
void)
const
104 return(_ellipseIntensity);
107double Magick::ChannelMoments::huInvariants(
const size_t index_)
const
112 return(_huInvariants.at(index_));
115Magick::ImageMoments::ImageMoments(
void)
120Magick::ImageMoments::ImageMoments(
const ImageMoments &imageMoments_)
121 : _channels(imageMoments_._channels)
125Magick::ImageMoments::~ImageMoments(
void)
129Magick::ChannelMoments Magick::ImageMoments::channel(
130 const ChannelType channel_)
const
132 for (std::vector<ChannelMoments>::const_iterator it = _channels.begin();
133 it != _channels.end(); ++it)
135 if (it->channel() == channel_)
141Magick::ImageMoments::ImageMoments(
const Image &image_)
144 MagickCore::ChannelMoments*
148 channel_moments=GetImageChannelMoments(image_.constImage(),exceptionInfo);
149 if (channel_moments != (MagickCore::ChannelMoments *) NULL)
151 switch(image_.constImage()->colorspace)
156 &channel_moments[RedChannel]));
158 &channel_moments[GreenChannel]));
160 &channel_moments[BlueChannel]));
164 &channel_moments[CyanChannel]));
166 &channel_moments[MagentaChannel]));
168 &channel_moments[YellowChannel]));
170 &channel_moments[BlackChannel]));
174 &channel_moments[GrayChannel]));
177 if (image_.constImage()->matte != MagickFalse)
179 &channel_moments[AlphaChannel]));
180 if (image_.constImage()->colorspace != GRAYColorspace)
182 &channel_moments[CompositeChannels]));
183 channel_moments=(MagickCore::ChannelMoments *) RelinquishMagickMemory(
186 ThrowPPException(image_.quiet());