当前位置: 首页>>代码示例>>C#>>正文


C# MagickImage.Histogram方法代码示例

本文整理汇总了C#中ImageMagick.MagickImage.Histogram方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Histogram方法的具体用法?C# MagickImage.Histogram怎么用?C# MagickImage.Histogram使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageMagick.MagickImage的用法示例。


在下文中一共展示了MagickImage.Histogram方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadHistogram

 private void LoadHistogram(FileItem fileItem, MagickImage bitmap)
 {
     fileItem.FileInfo.HistogramBlue = new int[256];
     fileItem.FileInfo.HistogramGreen = new int[256];
     fileItem.FileInfo.HistogramRed = new int[256];
     fileItem.FileInfo.HistogramLuminance = new int[256];
     Dictionary<MagickColor, int> h = bitmap.Histogram();
     foreach (var i in h)
     {
         byte R = i.Key.R;
         byte G = i.Key.G;
         byte B = i.Key.B;
         fileItem.FileInfo.HistogramBlue[B] += i.Value;
         fileItem.FileInfo.HistogramGreen[G] += i.Value;
         fileItem.FileInfo.HistogramRed[R] += i.Value;
         int lum = (R + R + R + B + G + G + G + G) >> 3;
         fileItem.FileInfo.HistogramLuminance[lum] += i.Value;
     }
     //fileItem.FileInfo.HistogramBlue = SmoothHistogram(fileItem.FileInfo.HistogramBlue);
     //fileItem.FileInfo.HistogramGreen = SmoothHistogram(fileItem.FileInfo.HistogramGreen);
     //fileItem.FileInfo.HistogramRed = SmoothHistogram(fileItem.FileInfo.HistogramRed);
     //fileItem.FileInfo.HistogramLuminance = SmoothHistogram(fileItem.FileInfo.HistogramLuminance);
 }
开发者ID:btugade,项目名称:digiCamControl,代码行数:23,代码来源:BitmapLoader.cs

示例2: LoadHistogram

        public void LoadHistogram(FileItem item)
        {
            try
            {
                var fileInfo = item.FileInfo;
                if (fileInfo!=null)
                {
                    if (fileInfo.IsLoading)
                        return;
                    fileInfo.IsLoading = true;
                }
                if (fileInfo == null || fileInfo.ExifTags == null || fileInfo.ExifTags.Items.Count == 0)
                {
                    GetMetadata(item);
                    fileInfo = item.FileInfo;
                    fileInfo.IsLoading = true;
                }
                if (!File.Exists(item.SmallThumb))
                {
                    fileInfo.IsLoading = false;
                    return;
                }

                using (MagickImage image = new MagickImage(item.SmallThumb))
                {
                    var Blue = new int[256];
                    var Green = new int[256];
                    var Red = new int[256];
                    var Luminance = new int[256];
                    Dictionary<MagickColor, int> h = image.Histogram();
                    foreach (var i in h)
                    {
                        byte R = i.Key.R;
                        byte G = i.Key.G;
                        byte B = i.Key.B;
                        Blue[B] += i.Value;
                        Green[G] += i.Value;
                        Red[R] += i.Value;
                        int lum = (R + R + R + B + G + G + G + G) >> 3;
                        Luminance[lum] += i.Value;
                    }
                    fileInfo.HistogramBlue = Blue;
                    fileInfo.HistogramGreen = Green;
                    fileInfo.HistogramRed = Red;
                    fileInfo.HistogramLuminance = Luminance;
                    fileInfo.IsLoading = false;
                    item.FileInfo = fileInfo;
                }
                item.SaveInfo();
                if (ServiceProvider.Settings.SelectedBitmap.FileItem == item)
                {
                    SetData(ServiceProvider.Settings.SelectedBitmap,
                                 ServiceProvider.Settings.SelectedBitmap.FileItem);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Unable to load histogram", ex);
            }

            //item.FileInfo.HistogramBlue = SmoothHistogram(item.FileInfo.HistogramBlue);
            //item.FileInfo.HistogramGreen = SmoothHistogram(item.FileInfo.HistogramGreen);
            //item.FileInfo.HistogramRed = SmoothHistogram(item.FileInfo.HistogramRed);
            //item.FileInfo.HistogramLuminance = SmoothHistogram(item.FileInfo.HistogramLuminance);
        }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:65,代码来源:BitmapLoader.cs

示例3: Test_Histogram

    public void Test_Histogram()
    {
      MagickImage image = new MagickImage(Files.RedPNG);
      Dictionary<MagickColor, int> histogram = image.Histogram();

      Assert.IsNotNull(histogram);
      Assert.AreEqual(3, histogram.Count);

      MagickColor red = new MagickColor(Quantum.Max, 0, 0);
      MagickColor alphaRed = new MagickColor(Quantum.Max, 0, 0, 0);
      MagickColor halfAlphaRed = new MagickColor("#FF000080");

      foreach (MagickColor color in histogram.Keys)
      {
        if (color == red)
          Assert.AreEqual(50000, histogram[color]);
        else if (color == alphaRed)
          Assert.AreEqual(30000, histogram[color]);
        else if (color == halfAlphaRed)
          Assert.AreEqual(40000, histogram[color]);
        else
          Assert.Fail("Invalid color: " + color.ToString());
      }

      image.Dispose();
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:26,代码来源:MagickImageTests.cs


注:本文中的ImageMagick.MagickImage.Histogram方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。