Beispiel #1
0
 /// <summary>
 /// Constructor of the <see cref="Image"/> object. Don't use this constructor, use CreateImage* methods of <see cref="Context"/> object instead.
 /// </summary>
 public Image(IntPtr handle, Context context, MemoryObjectType objectType, MemoryFlags memoryFlags, Size size, UInt64 arraySize, ImageChannelOrder channelOrder, ImageChannelType channelType) :
     base(handle, context, objectType, memoryFlags)
 {
     Size         = size;
     ArraySize    = arraySize;
     ChannelOrder = channelOrder;
     ChannelType  = channelType;
 }
Beispiel #2
0
        /// <inheritdoc cref="IHttpService.GetImageStreamAsync(string, string, CancellationToken)"/>
        public static Task <Stream?> GetImageStreamAsync(this IHttpService httpService,
                                                         string?requestUri,
                                                         ImageChannelType channelType,
                                                         CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrWhiteSpace(requestUri))
            {
                return(Task.FromResult((Stream?)null));
            }
            var channelType_ = channelType.ToString();

            return(httpService.GetImageStreamAsync(requestUri, channelType_, cancellationToken));
        }
Beispiel #3
0
 public void SetImageChannelGain(ImageChannelType channelType, double gainScale)
 {
     try
     {
         Image <Gray, Byte>[] splits = Image.Split();
         int index = channelType2IndexDic[channelType];
         splits[index] = splits[index] * gainScale;
         CvInvoke.cvMerge(splits[0].Ptr, splits[1].Ptr, splits[2].Ptr, IntPtr.Zero, Image.Ptr);
     }
     catch (System.Exception ex)
     {
         logger.Error(ex.Message);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Creates a 3D <see cref="Image"/>.
 /// </summary>
 /// <param name="width">The width of the image.</param>
 /// <param name="height">The height of the image.</param>
 /// <param name="depth">The depth of the image.</param>
 /// <param name="memoryFlags">Is used to specify allocation and usage information about the image memory object being created.</param>
 /// <param name="channelOrder">Specifies the number of channels and the channel layout.</param>
 /// <param name="channelType">Describes the size of the channel data type.</param>
 /// <returns>A new image.</returns>
 public Image CreateImage3D(UInt64 width, UInt64 height, UInt64 depth, MemoryFlags memoryFlags, ImageChannelOrder channelOrder, ImageChannelType channelType)
 {
     return(CreateImage3D <dynamic>(null, width, height, depth, memoryFlags, channelOrder, channelType));
 }
Beispiel #5
0
        /// <summary>
        /// Creates a 3D <see cref="Image"/>.
        /// </summary>
        /// <typeparam name="DataType">The type of image data.</typeparam>
        /// <param name="data">An array of data to use with the image.</param>
        /// <param name="width">The width of the image.</param>
        /// <param name="height">The height of the image.</param>
        /// <param name="depth">The depth of the image.</param>
        /// <param name="memoryFlags">Is used to specify allocation and usage information about the image memory object being created.</param>
        /// <param name="channelOrder">Specifies the number of channels and the channel layout.</param>
        /// <param name="channelType">Describes the size of the channel data type.</param>
        /// <returns>A new image.</returns>
        public Image CreateImage3D <DataType>(DataType[] data, UInt64 width, UInt64 height, UInt64 depth, MemoryFlags memoryFlags, ImageChannelOrder channelOrder, ImageChannelType channelType)
        {
            ImageFormat format = new ImageFormat
            {
                ChannelOrder = channelOrder,
                ChannelType  = channelType
            };
            ImageDescriptor descriptor = new ImageDescriptor
            {
                ImageType       = MemoryObjectType.Image3D,
                Width           = new UIntPtr(width),
                Height          = new UIntPtr(height),
                Depth           = new UIntPtr(depth),
                ImageArraySize  = UIntPtr.Zero,
                ImageRowPitch   = UIntPtr.Zero,
                ImageSlicePitch = UIntPtr.Zero,
                NumMipLevels    = 0,
                NumSamples      = 0,
                Buffer          = IntPtr.Zero
            };

            return(CreateImage <DataType>(data, memoryFlags, format, descriptor));
        }
Beispiel #6
0
 /// <summary>
 /// Creates an array of 2D <see cref="Image"/>s.
 /// </summary>
 /// <param name="arraySize">The number of images in the image array.</param>
 /// <param name="width">The width of the image.</param>
 /// <param name="height">The height of the image.</param>
 /// <param name="memoryFlags">Is used to specify allocation and usage information about the image memory object being created.</param>
 /// <param name="channelOrder">Specifies the number of channels and the channel layout.</param>
 /// <param name="channelType">Describes the size of the channel data type.</param>
 /// <returns>A new image.</returns>
 public Image CreateImage2DArray(UInt64 arraySize, UInt64 width, UInt64 height, MemoryFlags memoryFlags, ImageChannelOrder channelOrder, ImageChannelType channelType)
 {
     return(CreateImage2DArray <dynamic>(null, arraySize, width, height, memoryFlags, channelOrder, channelType));
 }
Beispiel #7
0
 /// <summary>
 /// Creates a monodimensional <see cref="Image"/> using the data from a buffer.
 /// </summary>
 /// <param name="buffer">The buffer from where the image pixels are taken.</param>
 /// <param name="width">The width of the image.</param>
 /// <param name="memoryFlags">Is used to specify allocation and usage information about the image memory object being created.</param>
 /// <param name="channelOrder">Specifies the number of channels and the channel layout.</param>
 /// <param name="channelType">Describes the size of the channel data type.</param>
 /// <returns>A new image.</returns>
 public Image CreateImage1DBuffer(MemoryObject buffer, UInt64 width, MemoryFlags memoryFlags, ImageChannelOrder channelOrder, ImageChannelType channelType)
 {
     return(CreateImage1DBuffer <dynamic>(buffer, null, width, memoryFlags, channelOrder, channelType));
 }
Beispiel #8
0
 /// <summary>
 /// Creates a monodimensional <see cref="Image"/>.
 /// </summary>
 /// <param name="width">The width of the image.</param>
 /// <param name="memoryFlags">Is used to specify allocation and usage information about the image memory object being created.</param>
 /// <param name="channelOrder">Specifies the number of channels and the channel layout.</param>
 /// <param name="channelType">Describes the size of the channel data type.</param>
 /// <returns>A new image.</returns>
 public Image CreateImage1D(UInt64 width, MemoryFlags memoryFlags, ImageChannelOrder channelOrder, ImageChannelType channelType)
 {
     return(CreateImage1D <dynamic>(null, width, memoryFlags, channelOrder, channelType));
 }