Beispiel #1
0
        public Histogram CreateDipAzimuthHistogram(int numberOfClasses)
        {
            Histogram histogram = new Histogram(numberOfClasses, -Math.PI, +Math.PI);

            IRegularGrid2D dZdX = CreatePartialDerivativeIGrid();
            IRegularGrid2D dZdY = CreatePartialDerivativeJGrid();

            for (int i = 0; i < SizeI; ++i)
            {
                for (int j = 0; j < SizeJ; ++j)
                {
                    double?x = dZdX[i, j];
                    double?y = dZdY[i, j];
                    if (x.HasValue && y.HasValue)
                    {
                        if (x != 0.0 && y != 0.0)
                        {
                            double dipAzimuth = Math.Atan2(-y.Value, -x.Value); // Negate x and y to give down-dip rather than up-dip
                            histogram.Accumulate(dipAzimuth);
                        }
                    }
                }
            }
            return(histogram);
        }
      /// <summary>
      /// Generate histograms for the image. One histogram is generated for each color channel.
      /// You will need to call the Refresh function to do the painting afterward.
      /// </summary>
      /// <param name="image">The image to retrieve histogram from</param>
      /// <param name="numberOfBins">The number of bins for each histogram</param>
      public void GenerateHistograms(IImage image, int numberOfBins)
      {
         IImage[] channels = image.Split();
         Type imageType = Toolbox.GetBaseType(image.GetType(), "Image`2");
         IColor typeOfColor = Activator.CreateInstance(imageType.GetGenericArguments()[0]) as IColor;
         String[] channelNames = Reflection.ReflectColorType.GetNamesOfChannels(typeOfColor);
         System.Drawing.Color[] colors = Reflection.ReflectColorType.GetDisplayColorOfChannels(typeOfColor);

         float minVal, maxVal;
         #region Get the maximum and minimum color intensity values
         System.Type typeOfDepth = imageType.GetGenericArguments()[1];
         if (typeOfDepth == typeof(Byte))
         {
            minVal = 0.0f;
            maxVal = 256.0f;
         }
         else
         {
            #region obtain the maximum and minimum color value
            double[] minValues, maxValues;
            System.Drawing.Point[] minLocations, maxLocations;
            image.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);

            double min = minValues[0], max = maxValues[0];
            for (int i = 1; i < minValues.Length; i++)
            {
               if (minValues[i] < min) min = minValues[i];
               if (maxValues[i] > max) max = maxValues[i];
            }
            #endregion

            minVal = (float)min;
            maxVal = (float)max;
         }
         #endregion

         for (int i = 0; i < channels.Length; i++)
            using (Histogram hist = new Histogram(numberOfBins, new RangeF(minVal, maxVal)))
            {
               hist.Accumulate(new IImage[1] { channels[i] });
               AddHistogram(channelNames[i], colors[i], hist);
            }
      }