/// <summary>
 /// Initializes a new instance of the PerceptualHash class 
 /// </summary>
 /// <param name="channel">The channel.></param>
 /// <param name="srgbHuPhash">SRGB hu perceptual hash.</param>
 /// <param name="hclpHuPhash">Hclp hu perceptual hash.</param>
 /// <param name="hash">A string representation of this hash.</param>
 public ChannelPerceptualHash(PixelChannel channel, double[] srgbHuPhash, double[] hclpHuPhash, string hash)
 {
   Channel = channel;
   _SrgbHuPhash = srgbHuPhash;
   _HclpHuPhash = hclpHuPhash;
   _Hash = hash;
 }
Example #2
0
    internal static ChannelMoments Create(PixelChannel channel, IntPtr instance)
    {
      if (instance == IntPtr.Zero)
        return null;

      return new ChannelMoments(channel, instance);
    }
Example #3
0
    private static ChannelPerceptualHash CreateChannelPerceptualHash(MagickImage image, IntPtr list, PixelChannel channel)
    {
      IntPtr instance = NativePerceptualHash.GetInstance(image, list, channel);
      if (instance == IntPtr.Zero)
        return null;

      return new ChannelPerceptualHash(channel, instance);
    }
Example #4
0
    private void AddChannel(IntPtr list, PixelChannel channel)
    {
      IntPtr instance = NativeMoments.GetInstance(list, channel);

      ChannelMoments result = ChannelMoments.Create(channel, instance);
      if (result != null)
        _Channels.Add(result.Channel, result);
    }
Example #5
0
        private void AddChannel(IntPtr list, PixelChannel channel)
        {
            IntPtr instance = NativeMoments.GetInstance(list, channel);

            ChannelMoments result = ChannelMoments.Create(channel, instance);

            if (result != null)
            {
                _Channels.Add(result.Channel, result);
            }
        }
Example #6
0
 public static IntPtr GetInstance(IntPtr list, PixelChannel channel)
 {
     if (NativeLibrary.Is64Bit)
     {
         return(NativeMethods.X64.Statistics_GetInstance(list, (UIntPtr)channel));
     }
     else
     {
         return(NativeMethods.X86.Statistics_GetInstance(list, (UIntPtr)channel));
     }
 }
Example #7
0
 public static IntPtr GetInstance(MagickImage image, IntPtr list, PixelChannel channel)
 {
     if (NativeLibrary.Is64Bit)
     {
         return(NativeMethods.X64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel));
     }
     else
     {
         return(NativeMethods.X86.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel));
     }
 }
Example #8
0
        private void AddChannel(IntPtr list, PixelChannel channel)
        {
            var instance = NativeStatistics.GetInstance(list, channel);

            ChannelStatistics result = ChannelStatistics.Create(channel, instance);

            if (result != null)
            {
                _channels.Add(result.Channel, result);
            }
        }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the ChannelMoments class.
 /// </summary>
 /// <param name="channel">The channel of the moment.</param>
 /// <param name="centroid">The centroid.</param>
 /// <param name="ellipseAxis">The ellipse axis.</param>
 /// <param name="ellipseAngle">The ellipse angle.</param>
 /// <param name="ellipseEccentricity">The ellipse eccentricity.</param>
 /// <param name="ellipseIntensity">The ellipse intensity.</param>
 /// <param name="huInvariants">The Hu invariants.</param>
 public ChannelMoments(PixelChannel channel, PointD centroid, PointD ellipseAxis, double ellipseAngle,
                       double ellipseEccentricity, double ellipseIntensity, double[] huInvariants)
 {
     Channel             = channel;
     Centroid            = centroid;
     EllipseAxis         = ellipseAxis;
     EllipseAngle        = ellipseAngle;
     EllipseEccentricity = ellipseEccentricity;
     EllipseIntensity    = ellipseIntensity;
     _HuInvariants       = huInvariants;
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the ChannelMoments class.
 /// </summary>
 /// <param name="channel">The channel of the moment.</param>
 /// <param name="centroid">The centroid.</param>
 /// <param name="ellipseAxis">The ellipse axis.</param>
 /// <param name="ellipseAngle">The ellipse angle.</param>
 /// <param name="ellipseEccentricity">The ellipse eccentricity.</param>
 /// <param name="ellipseIntensity">The ellipse intensity.</param>
 /// <param name="huInvariants">The Hu invariants.</param>
 public ChannelMoments(PixelChannel channel, PointD centroid, PointD ellipseAxis, double ellipseAngle,
   double ellipseEccentricity, double ellipseIntensity, double[] huInvariants)
 {
   Channel = channel;
   Centroid = centroid;
   EllipseAxis = ellipseAxis;
   EllipseAngle = ellipseAngle;
   EllipseEccentricity = ellipseEccentricity;
   EllipseIntensity = ellipseIntensity;
   _HuInvariants = huInvariants;
 }
Example #11
0
    private ChannelMoments(PixelChannel channel, IntPtr instance)
    {
      Channel = channel;

      NativeChannelMoments nativeInstance = new NativeChannelMoments(instance);
      Centroid = PointD.FromPointInfo(nativeInstance.Centroid);
      EllipseAngle = nativeInstance.EllipseAngle;
      EllipseAxis = PointD.FromPointInfo(nativeInstance.EllipseAxis);
      EllipseEccentricity = nativeInstance.EllipseEccentricity;
      EllipseIntensity = nativeInstance.EllipseIntensity;
      SetHuInvariants(nativeInstance);
    }
        private ChannelMoments(PixelChannel channel, IntPtr instance)
        {
            Channel = channel;

            NativeChannelMoments nativeInstance = new NativeChannelMoments(instance);

            Centroid            = nativeInstance.Centroid.ToPointD();
            EllipseAngle        = nativeInstance.EllipseAngle;
            EllipseAxis         = nativeInstance.EllipseAxis.ToPointD();
            EllipseEccentricity = nativeInstance.EllipseEccentricity;
            EllipseIntensity    = nativeInstance.EllipseIntensity;
            SetHuInvariants(nativeInstance);
        }
Example #13
0
     public static IntPtr GetInstance(MagickImage image, IntPtr list, PixelChannel channel)
     {
 #if ANYCPU
         if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
         return(NativeMethods.X64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel));
 #endif
 #if ANYCPU
         else
 #endif
 #if !WIN64 || ANYCPU
         return(NativeMethods.X86.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel));
 #endif
     }
Example #14
0
 public static IntPtr GetInstance(MagickImage image, IntPtr list, PixelChannel channel)
 {
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   return NativeMethods.X64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   return NativeMethods.X86.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel);
   #endif
 }
Example #15
0
 public static IntPtr GetInstance(IntPtr list, PixelChannel channel)
 {
     #if PLATFORM_AnyCPU
     if (OperatingSystem.Is64Bit)
     #endif
     #if PLATFORM_x64 || PLATFORM_AnyCPU
     return(NativeMethods.X64.Moments_GetInstance(list, (UIntPtr)channel));
     #endif
     #if PLATFORM_AnyCPU
     else
     #endif
     #if PLATFORM_x86 || PLATFORM_AnyCPU
     return(NativeMethods.X86.Moments_GetInstance(list, (UIntPtr)channel));
     #endif
 }
Example #16
0
     public static IntPtr GetInstance(IntPtr list, PixelChannel channel)
     {
 #if ANYCPU
         if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
         return(NativeMethods.X64.Statistics_GetInstance(list, (UIntPtr)channel));
 #endif
 #if ANYCPU
         else
 #endif
 #if !WIN64 || ANYCPU
         return(NativeMethods.X86.Statistics_GetInstance(list, (UIntPtr)channel));
 #endif
     }
Example #17
0
 public static IntPtr GetInstance(IMagickImage image, IntPtr list, PixelChannel channel)
 {
     #if PLATFORM_AnyCPU
     if (NativeLibrary.Is64Bit)
     #endif
     #if PLATFORM_x64 || PLATFORM_AnyCPU
     return(NativeMethods.X64.PerceptualHash_GetInstance(image.GetInstance(), list, (UIntPtr)channel));
     #endif
     #if PLATFORM_AnyCPU
     else
     #endif
     #if PLATFORM_x86 || PLATFORM_AnyCPU
     return(NativeMethods.X86.PerceptualHash_GetInstance(image.GetInstance(), list, (UIntPtr)channel));
     #endif
 }
Example #18
0
 public static IntPtr GetInstance(IntPtr list, PixelChannel channel)
 {
     #if PLATFORM_AnyCPU
     if (NativeLibrary.Is64Bit)
     #endif
     #if PLATFORM_x64 || PLATFORM_AnyCPU
     return(NativeMethods.X64.Statistics_GetInstance(list, (UIntPtr)channel));
     #endif
     #if PLATFORM_AnyCPU
     else
     #endif
     #if PLATFORM_x86 || PLATFORM_AnyCPU
     return(NativeMethods.X86.Statistics_GetInstance(list, (UIntPtr)channel));
     #endif
 }
Example #19
0
 public static IntPtr GetInstance(IntPtr list, PixelChannel channel)
 {
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   return NativeMethods.X64.Moments_GetInstance(list, (UIntPtr)channel);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   return NativeMethods.X86.Moments_GetInstance(list, (UIntPtr)channel);
   #endif
 }
Example #20
0
 /// <summary>
 /// Initializes a new instance of the ChannelStatistics class.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="depth">Depth of the channel.</param>
 /// <param name="entropy">Entropy.</param>
 /// <param name="kurtosis">Kurtosis</param>
 /// <param name="maximum">Maximum value observed.</param>
 /// <param name="mean">Average (mean) value observed.</param>
 /// <param name="minimum">Minimum value observed.</param>
 /// <param name="skewness">Skewness.</param>
 /// <param name="standardDeviation">Standard deviation, sqrt(variance).</param>
 /// <param name="sum">Sum.</param>
 /// <param name="sumCubed">Sum cubed.</param>
 /// <param name="sumFourthPower">Sum fourth power.</param>
 /// <param name="sumSquared">Sum squared.</param>
 /// <param name="variance">Variance.</param>
 public ChannelStatistics(PixelChannel channel, int depth, double entropy, double kurtosis,
                          double maximum, double mean, double minimum, double skewness, double standardDeviation,
                          double sum, double sumCubed, double sumFourthPower, double sumSquared, double variance)
 {
     Channel           = channel;
     Depth             = depth;
     Entropy           = entropy;
     Kurtosis          = kurtosis;
     Maximum           = maximum;
     Mean              = mean;
     Minimum           = minimum;
     Skewness          = skewness;
     StandardDeviation = standardDeviation;
     Sum            = sum;
     SumCubed       = sumCubed;
     SumFourthPower = sumFourthPower;
     SumSquared     = sumSquared;
     Variance       = variance;
 }
Example #21
0
        private ChannelStatistics(PixelChannel channel, IntPtr instance)
        {
            Channel = channel;

            NativeChannelStatistics nativeInstance = new NativeChannelStatistics(instance);

            Depth             = nativeInstance.Depth;
            Entropy           = nativeInstance.Entropy;
            Kurtosis          = nativeInstance.Kurtosis;
            Maximum           = nativeInstance.Maximum;
            Mean              = nativeInstance.Mean;
            Minimum           = nativeInstance.Minimum;
            Skewness          = nativeInstance.Skewness;
            StandardDeviation = nativeInstance.StandardDeviation;
            Sum            = nativeInstance.Sum;
            SumCubed       = nativeInstance.SumCubed;
            SumFourthPower = nativeInstance.SumFourthPower;
            SumSquared     = nativeInstance.SumSquared;
            Variance       = nativeInstance.Variance;
        }
Example #22
0
            public static IntPtr GetInstance(IntPtr list, PixelChannel channel)
            {
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (OperatingSystem.IsArm64)
                #endif
                #if PLATFORM_arm64 || PLATFORM_AnyCPU
                result = NativeMethods.ARM64.Statistics_GetInstance(list, (UIntPtr)channel);
                #endif
                #if PLATFORM_AnyCPU
                else if (OperatingSystem.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.Statistics_GetInstance(list, (UIntPtr)channel);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.Statistics_GetInstance(list, (UIntPtr)channel);
                #endif
                return(result);
            }
Example #23
0
            public static IntPtr GetInstance(IMagickImage?image, IntPtr list, PixelChannel channel)
            {
                IntPtr result;

                #if PLATFORM_AnyCPU
                if (OperatingSystem.IsArm64)
                #endif
                #if PLATFORM_arm64 || PLATFORM_AnyCPU
                result = NativeMethods.ARM64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel);
                #endif
                #if PLATFORM_AnyCPU
                else if (OperatingSystem.Is64Bit)
                #endif
                #if PLATFORM_x64 || PLATFORM_AnyCPU
                result = NativeMethods.X64.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel);
                #endif
                #if PLATFORM_AnyCPU
                else
                #endif
                #if PLATFORM_x86 || PLATFORM_AnyCPU
                result = NativeMethods.X86.PerceptualHash_GetInstance(MagickImage.GetInstance(image), list, (UIntPtr)channel);
                #endif
                return(result);
            }
Example #24
0
 /// <summary>
 /// Gets the moments for the specified channel.
 /// </summary>
 /// <param name="channel">The channel to get the moments for.</param>
 /// <returns>The moments for the specified channel.</returns>
 public ChannelMoments GetChannel(PixelChannel channel)
 {
     _channels.TryGetValue(channel, out ChannelMoments moments);
     return(moments);
 }
Example #25
0
 internal ChannelPerceptualHash(PixelChannel channel, string hash)
     : this(channel)
 {
     ParseHash(hash);
 }
Example #26
0
 ///<summary>
 /// Returns the index of the specified channel. Returns -1 if not found.
 ///</summary>
 ///<param name="channel">The channel to get the index of.</param>
 public int GetIndex(PixelChannel channel)
 {
     return(_Image.ChannelOffset(channel));
 }
 internal ChannelPerceptualHash(PixelChannel channel, string hash)
   : this(channel)
 {
   ParseHash(hash);
 }
Example #28
0
 public int GetIndex(PixelChannel channel)
 => Image.ChannelOffset(channel);
Example #29
0
 /// <summary>
 /// Gets the moments for the specified channel.
 /// </summary>
 /// <param name="channel">The channel to get the moments for.</param>
 /// <returns>The moments for the specified channel.</returns>
 public ChannelMoments GetChannel(PixelChannel channel)
 {
   ChannelMoments moments;
   _Channels.TryGetValue(channel, out moments);
   return moments;
 }
 internal ChannelPerceptualHash(PixelChannel channel)
 {
     Channel      = channel;
     _hclpHuPhash = new double[7];
     _srgbHuPhash = new double[7];
 }
Example #31
0
    public void Test_Channels()
    {
      PixelChannel[] rgb = new PixelChannel[]
      {
        PixelChannel.Red, PixelChannel.Green, PixelChannel.Blue
      };

      PixelChannel[] rgba = new PixelChannel[]
      {
        PixelChannel.Red, PixelChannel.Green, PixelChannel.Blue, PixelChannel.Alpha
      };

      PixelChannel[] gray = new PixelChannel[]
      {
        PixelChannel.Gray
      };

      PixelChannel[] grayAlpha = new PixelChannel[]
      {
        PixelChannel.Gray, PixelChannel.Alpha
      };

      PixelChannel[] cmyk = new PixelChannel[]
      {
        PixelChannel.Cyan, PixelChannel.Magenta, PixelChannel.Yellow, PixelChannel.Black
      };

      PixelChannel[] cmyka = new PixelChannel[]
      {
        PixelChannel.Cyan, PixelChannel.Magenta, PixelChannel.Yellow, PixelChannel.Black, PixelChannel.Alpha
      };

      using (MagickImage image = new MagickImage(Files.RoseSparkleGIF))
      {
        CollectionAssert.AreEqual(rgba, image.Channels.ToArray());

        image.Alpha(AlphaOption.Off);

        CollectionAssert.AreEqual(rgb, image.Channels.ToArray());
      }

      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        CollectionAssert.AreEqual(grayAlpha, image.Channels.ToArray());

        using (MagickImage redChannel = image.Separate(Channels.Red).First())
        {
          CollectionAssert.AreEqual(gray, redChannel.Channels.ToArray());

          redChannel.Alpha(AlphaOption.On);

          CollectionAssert.AreEqual(grayAlpha, redChannel.Channels.ToArray());
        }
      }

      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        image.ColorSpace = ColorSpace.CMYK;

        CollectionAssert.AreEqual(cmyka, image.Channels.ToArray());

        image.Alpha(AlphaOption.Off);

        CollectionAssert.AreEqual(cmyk, image.Channels.ToArray());
      }
    }
Example #32
0
        private static ChannelPerceptualHash CreateChannelPerceptualHash(MagickImage image, IntPtr list, PixelChannel channel)
        {
            IntPtr instance = NativePerceptualHash.GetInstance(image, list, channel);

            if (instance == IntPtr.Zero)
            {
                return(null);
            }

            return(new ChannelPerceptualHash(channel, instance));
        }
 internal ChannelPerceptualHash(PixelChannel channel, IntPtr instance)
   : this(channel)
 {
   NativeChannelPerceptualHash nativeInstance = new NativeChannelPerceptualHash(instance);
   SetSrgbHuPhash(nativeInstance);
   SetHclpHuPhash(nativeInstance);
   SetHash();
 }
Example #34
0
 public bool HasChannel(PixelChannel channel)
 {
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   return NativeMethods.X64.MagickImage_HasChannel(Instance, (UIntPtr)channel);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   return NativeMethods.X86.MagickImage_HasChannel(Instance, (UIntPtr)channel);
   #endif
 }
Example #35
0
 /// <summary>
 /// Returns the perceptual hash for the specified channel.
 /// </summary>
 /// <param name="channel">The channel to get the has for.</param>
 /// <returns>The perceptual hash for the specified channel.</returns>
 public IChannelPerceptualHash GetChannel(PixelChannel channel)
 {
     _channels.TryGetValue(channel, out ChannelPerceptualHash perceptualHash);
     return(perceptualHash);
 }
Example #36
0
 private void AddChannel(MagickImage image, IntPtr list, PixelChannel channel)
 {
   ChannelPerceptualHash instance = CreateChannelPerceptualHash(image, list, channel);
   if (instance != null)
     _Channels.Add(instance.Channel, instance);
 }
 internal ChannelPerceptualHash(PixelChannel channel)
 {
   Channel = channel;
   _HclpHuPhash = new double[7];
   _SrgbHuPhash = new double[7];
 }
Example #38
0
 /// <summary>
 /// Returns the perceptual hash for the specified channel.
 /// </summary>
 /// <param name="channel">The channel to get the has for.</param>
 /// <returns>The perceptual hash for the specified channel.</returns>
 public ChannelPerceptualHash GetChannel(PixelChannel channel)
 {
   ChannelPerceptualHash perceptualHash;
   _Channels.TryGetValue(channel, out perceptualHash);
   return perceptualHash;
 }
 ///<summary>
 /// Returns the index of the specified channel. Returns -1 if not found.
 ///</summary>
 ///<param name="channel">The channel to get the index of.</param>
 public int GetIndex(PixelChannel channel)
 {
     return(_Instance.GetIndex(channel));
 }
Example #40
0
 /// <summary>
 /// Returns the statistics for the specified channel.
 /// </summary>
 /// <param name="channel">The channel to get the statistics for.</param>
 /// <returns>The statistics for the specified channel.</returns>
 public ChannelStatistics GetChannel(PixelChannel channel)
 {
     _channels.TryGetValue(channel, out ChannelStatistics channelStatistics);
     return(channelStatistics);
 }
Example #41
0
 public int ChannelOffset(PixelChannel channel)
 {
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   return (int)NativeMethods.X64.MagickImage_ChannelOffset(Instance, (UIntPtr)channel);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   return (int)NativeMethods.X86.MagickImage_ChannelOffset(Instance, (UIntPtr)channel);
   #endif
 }