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


C# IImage.GetType方法代码示例

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


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

示例1: GetTypeOfDepth

      /// <summary>
      /// Get the depth type of the image
      /// </summary>
      /// <param name="image">The image to apply reflection on</param>
      /// <returns>The depth type of the image</returns>
      public static Type GetTypeOfDepth(IImage image)
      {
         Type baseType = Toolbox.GetBaseType(image.GetType(), "Image`2");
         if (baseType == null)
            baseType = Toolbox.GetBaseType(image.GetType(), "GpuImage`2");

         return baseType == null ? null : baseType.GetGenericArguments()[1];
      }
开发者ID:KaganRoman,项目名称:Eval,代码行数:13,代码来源:ReflectIImage.cs

示例2: GetTypeOfDepth

      /// <summary>
      /// Get the depth type of the image
      /// </summary>
      /// <param name="image">The image to apply reflection on</param>
      /// <returns>The depth type of the image</returns>
      public static Type GetTypeOfDepth(IImage image)
      {
         Type baseType = Toolbox.GetBaseType(image.GetType(), "Image`2") ??
                         Toolbox.GetBaseType(image.GetType(), "CudaImage`2");

         if (baseType != null)
            return baseType.GetGenericArguments()[1];
         else
         {
            baseType = Toolbox.GetBaseType(image.GetType(), "Mat");
            return
               baseType == null ? null :
               CvInvoke.GetDepthType((image as Mat).Depth);
         }
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:20,代码来源:ReflectIImage.cs

示例3: GetTypeOfDepth

 /// <summary>
 /// Get the depth type of the image
 /// </summary>
 /// <param name="image">The image to apply reflection on</param>
 /// <returns>The depth type of the image</returns>
 public static Type GetTypeOfDepth(IImage image)
 {
    return 
       Toolbox
       .GetBaseType(image.GetType(), "Image`2")
       .GetGenericArguments()[1];
 }
开发者ID:Rustemt,项目名称:emgu_openCV,代码行数:12,代码来源:ReflectIImage.cs

示例4: GetTypeOfColor

      /// <summary>
      /// Get the color type of the image
      /// </summary>
      /// <param name="image">The image to apply reflection on</param>
      /// <returns>The color type of the image</returns>
      public static Type GetTypeOfColor(IImage image)
      {
         Type baseType =  Toolbox.GetBaseType(image.GetType(), "Image`2") ??
                          Toolbox.GetBaseType(image.GetType(), "CudaImage`2");

         if (baseType != null)
            return baseType.GetGenericArguments()[0];
         else
         {
            baseType = Toolbox.GetBaseType(image.GetType(), "Mat");
            return
               baseType == null ? null :
               image.NumberOfChannels == 1 ? typeof(Gray) :
               image.NumberOfChannels == 3 ? typeof(Bgr) :
               image.NumberOfChannels == 4 ? typeof(Bgra) :
               null;
         }
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:23,代码来源:ReflectIImage.cs

示例5: GetPixelColor

      /// <summary>
      /// Get the color at the specific location of the image
      /// </summary>
      /// <param name="image">The image to obtain pixel value from</param>
      /// <param name="location">The location to sample a pixel</param>
      /// <returns>The color at the specific location</returns>
      public static IColor GetPixelColor(IImage image, Point location)
      {
         Size size = image.Size;
         location.X = Math.Min(location.X, size.Width - 1);
         location.Y = Math.Min(location.Y, size.Height - 1);

         MethodInfo indexers =
            image.GetType()
            .GetMethod("get_Item", new Type[2] { typeof(int), typeof(int) });

         return indexers == null ?
            new Bgra()
            : indexers.Invoke(image, new object[2] { location.Y, location.X }) as IColor;
      }
开发者ID:Rustemt,项目名称:emgu_openCV,代码行数:20,代码来源:ReflectIImage.cs

示例6: GetImageMethods

 /// <summary>
 /// Get all the methods that belongs to the IImage and Image class with ExposableMethodAttribute set true.
 /// </summary>
 /// <param name="image">The IImage object to be refelected for methods marked with ExposableMethodAttribute</param>
 /// <returns>All the methods that belongs to the IImage and Image class with ExposableMethodAttribute set true</returns>
 public static IEnumerable<KeyValuePair<String, MethodInfo>> GetImageMethods(IImage image)
 {
    if (image != null)
    {
       foreach (MethodInfo mi in image.GetType().GetMethods())
       {
          Object[] atts = mi.GetCustomAttributes(typeof(ExposableMethodAttribute), false);
          if (atts.Length > 0)
          {
             ExposableMethodAttribute att = (ExposableMethodAttribute)atts[0];
             if (att.Exposable)
                yield return new KeyValuePair<String, MethodInfo>(att.Category, mi);
          }
       }
    }
 }
开发者ID:neutmute,项目名称:emgucv,代码行数:21,代码来源:ReflectIImage.cs

示例7: GetImageMethods

      /// <summary>
      /// Get all the methods that belongs to the IImage and Image class with ExposableMethodAttribute set true.
      /// </summary>
      /// <returns></returns>
      public static IEnumerable<KeyValuePair<String, MethodInfo>> GetImageMethods(IImage image)
      {
         if (image != null)
         {
            List<MethodInfo> methods = new List<MethodInfo>();
            methods.AddRange(image.GetType().GetMethods());
            //methods.AddRange(image.GetType().GetInterface("IImage").GetMethods());

            foreach (MethodInfo mi in methods)
            {
               Object[] atts = mi.GetCustomAttributes(typeof(ExposableMethodAttribute), false);
               if (atts.Length > 0)
               {
                  ExposableMethodAttribute att = (ExposableMethodAttribute)atts[0];
                  if (att.Exposable)
                     yield return new KeyValuePair<String, MethodInfo>(att.Category, mi as MethodInfo);
               }
            }
         }
      }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:24,代码来源:ReflectIImage.cs

示例8: BuildOperationMenuItem

        private void BuildOperationMenuItem(IImage image)
        {
            Type typeOfImage = image.GetType();

             filtersToolStripMenuItem.DropDownItems.Clear();

             //check if the menu for the specific image type has been built before
             if (!_typeToToolStripMenuItemsDictionary.ContainsKey(typeOfImage))
             {
            //if not built, build it and save to the cache.
            _typeToToolStripMenuItemsDictionary.Add(
               typeOfImage,
               BuildOperationTree(Reflection.ReflectIImage.GetImageMethods(image))
               );
             }

             filtersToolStripMenuItem.DropDownItems.AddRange(_typeToToolStripMenuItemsDictionary[typeOfImage]);
        }
开发者ID:wendellinfinity,项目名称:ShoulderSurferAlert,代码行数:18,代码来源:ImageBox.cs

示例9: GenerateHistograms

      /// <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 generate histogram from</param>
      /// <param name="numberOfBins">The number of bins for each histogram</param>
      public void GenerateHistograms(IImage image, int numberOfBins)
      {
         Mat[] channels = new Mat[image.NumberOfChannels];
         Type imageType; 
         if ((imageType = Toolbox.GetBaseType(image.GetType(), "Image`2")) != null 
            || (imageType = Toolbox.GetBaseType(image.GetType(), "Mat")) != null)
         {
            for (int i = 0; i < image.NumberOfChannels; i++)
            {
               Mat channel = new Mat();
               CvInvoke.ExtractChannel(image, channel, i);
               channels[i] = channel;
            }
             
         }
         else if ((imageType = Toolbox.GetBaseType(image.GetType(), "CudaImage`2")) != null)
         {
            IImage img = imageType.GetMethod("ToImage").Invoke(image, null) as IImage;
            for (int i = 0; i < img.NumberOfChannels; i++)
            {
               Mat channel = new Mat();
               CvInvoke.ExtractChannel(img, channel, i);
               channels[i] = channel;
            }
         }
         else
         {
            throw new ArgumentException(String.Format("The input image type of {0} is not supported", image.GetType().ToString()));
         }

         Type[] genericArguments = imageType.GetGenericArguments();
         String[] channelNames;
         Color[] colors;
         Type typeOfDepth;
         if (genericArguments.Length > 0)
         {
            IColor typeOfColor = Activator.CreateInstance(genericArguments[0]) as IColor;
            channelNames = Reflection.ReflectColorType.GetNamesOfChannels(typeOfColor);
            colors = Reflection.ReflectColorType.GetDisplayColorOfChannels(typeOfColor);
            typeOfDepth = imageType.GetGenericArguments()[1];
         }
         else
         {
            channelNames = new String[image.NumberOfChannels];
            colors = new Color[image.NumberOfChannels];
            for (int i = 0; i < image.NumberOfChannels; i++)
            {
               channelNames[i] = String.Format("Channel {0}", i);
               colors[i] = Color.Red;
            }

            if (image is Mat)
            {
               typeOfDepth = CvInvoke.GetDepthType(((Mat)image).Depth);
            }
            else
            {
               throw new ArgumentException(String.Format("Unable to get the type of depth from image of type {0}", image.GetType().ToString()));
            }
            
         }
         
         float minVal, maxVal;
         #region Get the maximum and minimum color intensity values
         
         if (typeOfDepth == typeof(Byte))
         {
            minVal = 0.0f;
            maxVal = 256.0f;
         }
         else
         {
            #region obtain the maximum and minimum color value
            double[] minValues, maxValues;
            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 (DenseHistogram hist = new DenseHistogram(numberOfBins, new RangeF(minVal, maxVal)))
//.........这里部分代码省略.........
开发者ID:reidblomquist,项目名称:emgucv,代码行数:101,代码来源:HistogramBox.cs

示例10: GetImage

        D2D1.Bitmap GetImage(IImage image)
        {
            if (image == null)
                return null;

            var wbi = image as WICBitmapSourceImage;
            if (wbi != null) {
                Guid renderFormat = WIC.PixelFormat.Format32bppPBGRA;
                if (wbi.Bitmap.PixelFormat != renderFormat) {
                    //System.Diagnostics.Debug.WriteLine ("RT  FORMAT: " + renderTarget.PixelFormat.Format);
                    //System.Diagnostics.Debug.WriteLine ("BMP FORMAT: " + wbi.Bitmap.PixelFormat);
                    var c = new WIC.FormatConverter (factories.WICFactory);
                    c.Initialize (wbi.Bitmap, renderFormat);
                    //System.Diagnostics.Debug.WriteLine ("CO  FORMAT: " + c.PixelFormat);
                    return D2D1.Bitmap.FromWicBitmap (renderTarget, c);
                }
                else {
                    return D2D1.Bitmap.FromWicBitmap (renderTarget, wbi.Bitmap);
                }
            }

            throw new NotSupportedException ("Image type " + image.GetType () + " not supported");
        }
开发者ID:rbrian,项目名称:NGraphics,代码行数:23,代码来源:Direct2DCanvas.cs

示例11: GenerateHistograms

        /// <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 generate 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);
             Color[] colors = Reflection.ReflectColorType.GetDisplayColorOfChannels(typeOfColor);

             float minVal, maxVal;
             #region Get the maximum and minimum color intensity values
             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;
            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 (DenseHistogram hist = new DenseHistogram(numberOfBins, new RangeF(minVal, maxVal)))
            {
               hist.Calculate(new IImage[1] { channels[i] }, true, null);
               AddHistogram(channelNames[i], colors[i], hist);
            }
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:49,代码来源:HistogramBox.cs

示例12: SetImage

        public void SetImage(IImage image)
        {
            #region display the size of the image
             Size size = image.Size;
             widthTextbox.Text = size.Width.ToString();
             heightTextBox.Text = size.Height.ToString();
             #endregion

             #region display the color type of the image
             Type colorType = Reflection.ReflectIImage.GetTypeOfColor(image);
             Object[] colorAttributes = colorType.GetCustomAttributes(typeof(ColorInfoAttribute), true);
             if (colorAttributes.Length > 0)
             {
            ColorInfoAttribute info = (ColorInfoAttribute)colorAttributes[0];
            typeOfColorTexbox.Text = info.ConversionCodename;
             }
             else
             {
            typeOfColorTexbox.Text = Properties.StringTable.Unknown;
             }

             Type colorDepth = Reflection.ReflectIImage.GetTypeOfDepth(image);
             typeOfDepthTextBox.Text = colorDepth.Name;
             #endregion

             #region check if image is a subclass of CvArr type
             Type imageType = image.GetType();
             isCvArray = true;
             Type cvArrayType = typeof(CvArray<>);
             while (cvArrayType != imageType)
             {
            if (imageType.IsGenericType && imageType.GetGenericTypeDefinition() == cvArrayType)
            {
               break;
            }
            imageType = imageType.BaseType;
            if (imageType == null)
            {
               isCvArray = false;
               break;
            }
             }
             #endregion

             UpdateHistogram();
             UpdateZoomScale();
        }
开发者ID:wendellinfinity,项目名称:ShoulderSurferAlert,代码行数:47,代码来源:ImageProperty.cs


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