public void GetImage(TColourFormat format, CVImage target) { if (format == this.NativeFormat) ImageUtils.CopyImage(this, target); else ImageUtils.CopyImageConverted(this, target); }
public static IImage CreateImage(int width, int height, TColourFormat format) { switch (format) { case TColourFormat.L8: return(new Image <Gray, byte>(width, height)); case TColourFormat.L16: return(new Image <Gray, ushort>(width, height)); case TColourFormat.L32S: return(new Image <Gray, int>(width, height)); case TColourFormat.L32F: return(new Image <Gray, float>(width, height)); case TColourFormat.RGB8: return(new Image <Rgb, byte>(width, height)); case TColourFormat.RGB32F: return(new Image <Rgb, float>(width, height)); case TColourFormat.RGBA8: return(new Image <Rgba, byte>(width, height)); case TColourFormat.RGBA32F: return(new Image <Rgba, float>(width, height)); } throw (new NotImplementedException("We have not implemented the automatic creation of this image type")); }
public static COLOR_CONVERSION ConvertRoute(TColourFormat src, TColourFormat dst) { switch (src) { case TColourFormat.L8: { switch (dst) { case TColourFormat.RGBA8: return(COLOR_CONVERSION.CV_GRAY2RGBA); } break; } case TColourFormat.RGB8: { switch (dst) { case TColourFormat.L8: return(COLOR_CONVERSION.CV_RGB2GRAY); case TColourFormat.RGBA8: return(COLOR_CONVERSION.CV_RGB2RGBA); } break; } } return(COLOR_CONVERSION.CV_COLORCVT_MAX); }
public static string AsString(TColourFormat format) { switch (format) { case TColourFormat.L8: return("L8"); case TColourFormat.L16: return("L16"); case TColourFormat.RGB8: return("RGB8"); case TColourFormat.RGB32F: return("RGB32F"); case TColourFormat.RGBA8: return("RGBA8"); case TColourFormat.RGBA32F: return("RGBA32F"); default: throw (new NotImplementedException("We haven't implemented AsString for this type")); } }
public static int ChannelCount(TColourFormat format) { switch (format) { case TColourFormat.L8: return(1); case TColourFormat.L16: return(1); case TColourFormat.RGB8: return(3); case TColourFormat.RGB32F: return(3); case TColourFormat.RGBA8: return(4); case TColourFormat.RGBA32F: return(4); default: return(0); } }
public static uint BytesPerPixel(TColourFormat format) { switch (format) { case TColourFormat.L8: return(1); case TColourFormat.L16: return(2); case TColourFormat.RGB8: return(3); case TColourFormat.RGB32F: return(3 * sizeof(float)); case TColourFormat.RGBA8: return(4); case TColourFormat.RGBA32F: return(4 * sizeof(float)); default: throw(new NotImplementedException("We haven't implemented BytesPerPixel for this type")); } }
public static IImage CreateImage(int width, int height, TColourFormat format) { switch(format) { case TColourFormat.L8: return new Image<Gray, byte>(width, height); case TColourFormat.L16: return new Image<Gray, ushort>(width, height); case TColourFormat.L32S: return new Image<Gray, int>(width, height); case TColourFormat.L32F: return new Image<Gray, float>(width, height); case TColourFormat.RGB8: return new Image<Rgb, byte>(width, height); case TColourFormat.RGB32F: return new Image<Rgb, float>(width, height); case TColourFormat.RGBA8: return new Image<Rgba, byte>(width, height); case TColourFormat.RGBA32F: return new Image<Rgba, float>(width, height); } throw (new NotImplementedException("We have not implemented the automatic creation of this image type")); }
public static Texture CreateTexture(CVImageAttributes attributes, Device device) { TColourFormat format = attributes.ColourFormat; TColourFormat newFormat; bool useConverted = NeedsConversion(format, out newFormat); return(new Texture(device, Math.Max(attributes.Width, 1), Math.Max(attributes.Height, 1), 1, Usage.None, GetDXFormat(useConverted ? newFormat : format), Pool.Managed)); }
public void GetImage(TColourFormat format, CVImage target) { if (format == this.NativeFormat) { ImageUtils.CopyImage(this, target); } else { ImageUtils.CopyImageConverted(this, target); } }
public bool Initialise(System.Drawing.Size size, TColourFormat format) { bool changedAttributes = FImageAttributes.CheckChanges(format, size); if (changedAttributes || this.Allocated == false) { Allocate(); return true; } else return false; }
public static bool NeedsConversion(TColourFormat format, out TColourFormat targetFormat) { switch (format) { case TColourFormat.RGB8: targetFormat = TColourFormat.RGBA8; return(true); default: targetFormat = TColourFormat.UnInitialised; return(false); } }
public static unsafe Spread <double> GetPixelAsDoubles(CVImage source, uint column, uint row) { TColourFormat format = source.ImageAttributes.ColourFormat; uint channelCount = (uint)ChannelCount(format); if (channelCount == 0) { return(new Spread <double>(0)); } uint width = (uint)source.Width; uint height = (uint)source.Height; Spread <double> output = new Spread <double>((int)channelCount); row %= height; column %= width; switch (ChannelFormat(format)) { case TChannelFormat.Byte: { byte *d = (byte *)source.Data.ToPointer(); for (uint channel = 0; channel < channelCount; channel++) { output[(int)channel] = (double)d[(column + row * width) * channelCount + channel]; } break; } case TChannelFormat.Float: { float *d = (float *)source.Data.ToPointer(); for (uint channel = 0; channel < channelCount; channel++) { output[(int)channel] = (double)d[(column + row * width) * channelCount + channel]; } break; } case TChannelFormat.UShort: { ushort *d = (ushort *)source.Data.ToPointer(); for (uint channel = 0; channel < channelCount; channel++) { output[(int)channel] = (double)d[(column + row * width) * channelCount + channel]; } break; } } return(output); }
public unsafe bool SetImage(IImage source) { if (source == null) { return(false); } TColourFormat sourceFormat = ImageUtils.GetFormat(source); bool Reinitialise = Initialise(source.Size, sourceFormat); ImageUtils.CopyImage(source, this); return(Reinitialise); }
public bool Initialise(System.Drawing.Size size, TColourFormat format) { bool changedAttributes = FImageAttributes.CheckChanges(format, size); if (changedAttributes) { Allocate(); return(true); } else { return(false); } }
public bool CheckChanges(TColourFormat c, Size s) { bool changed = false; if (c != ColourFormat) { ColourFormat = c; changed = true; } if (s != FSize) { FSize = s; changed = true; } return changed; }
public static Format GetDXFormat(TColourFormat format) { switch (format) { case TColourFormat.L8: return(Format.L8); case TColourFormat.L16: return(Format.L16); case TColourFormat.RGBA8: return(Format.A8R8G8B8); default: throw (new NotImplementedException("Cannot create a texture to match Image's format")); } }
public bool CheckChanges(TColourFormat c, Size s) { bool changed = false; if (c != ColourFormat) { ColourFormat = c; changed = true; } if (s != FSize) { FSize = s; changed = true; } return(changed); }
public static TChannelFormat ChannelFormat(TColourFormat format) { switch (format) { case TColourFormat.L8: case TColourFormat.RGB8: case TColourFormat.RGBA8: return(TChannelFormat.Byte); case TColourFormat.L16: return(TChannelFormat.UShort); case TColourFormat.L32F: case TColourFormat.RGB32F: case TColourFormat.RGBA32F: return(TChannelFormat.Float); default: throw (new Exception("We haven't implemented ChannelFormat for this TColourFormat")); } }
public static COLOR_CONVERSION ConvertRoute(TColourFormat src, TColourFormat dst) { switch (src) { case TColourFormat.L8: { switch (dst) { case TColourFormat.RGBA8: return COLOR_CONVERSION.CV_GRAY2RGBA; } break; } case TColourFormat.RGB8: { switch (dst) { case TColourFormat.L8: return COLOR_CONVERSION.CV_RGB2GRAY; case TColourFormat.RGBA8: return COLOR_CONVERSION.CV_RGB2RGBA; } break; } case TColourFormat.RGB32F: { switch (dst) { case TColourFormat.RGBA32F: return COLOR_CONVERSION.CV_RGB2RGBA; } break; } } return COLOR_CONVERSION.CV_COLORCVT_MAX; }
public CVImageAttributes() { ColourFormat = TColourFormat.UnInitialised; FSize = new Size(0, 0); }
public static bool NeedsConversion(TColourFormat format, out TColourFormat targetFormat) { switch(format) { case TColourFormat.RGB8: targetFormat = TColourFormat.RGBA8; return true; case TColourFormat.RGB32F: targetFormat = TColourFormat.RGBA32F; return true; default: targetFormat = TColourFormat.UnInitialised; return false; } }
public static string AsString(TColourFormat format) { switch (format) { case TColourFormat.L8: return "L8"; case TColourFormat.L16: return "L16"; case TColourFormat.RGB8: return "RGB8"; case TColourFormat.RGB32F: return "RGB32F"; case TColourFormat.RGBA8: return "RGBA8"; default: throw (new NotImplementedException("We haven't implemented AsString for this type")); } }
public static Format GetDXFormat(TColourFormat format) { switch (format) { case TColourFormat.L8: return Format.L8; case TColourFormat.L16: return Format.L16; case TColourFormat.RGBA32F: return Format.A32B32G32R32F; case TColourFormat.RGBA8: return Format.A8R8G8B8; default: throw (new NotImplementedException("Cannot create a texture to match Image's format")); } }
public static int ChannelCount(TColourFormat format) { switch (format) { case TColourFormat.L8: return 1; case TColourFormat.L16: return 1; case TColourFormat.RGB8: return 3; case TColourFormat.RGB32F: return 3; case TColourFormat.RGBA8: return 4; case TColourFormat.RGBA32F: return 4; default: return 0; } }
public static uint BytesPerPixel(TColourFormat format) { switch (format) { case TColourFormat.L8: return 1; case TColourFormat.L16: return 2; case TColourFormat.RGB8: return 3; case TColourFormat.RGB32F: return 3 * sizeof(float); case TColourFormat.RGBA8: return 4; case TColourFormat.RGBA32F: return 4 * sizeof(float); default: throw(new NotImplementedException("We haven't implemented BytesPerPixel for this type")); } }
public CVImageAttributes(Size size, TColourFormat format) { FSize = size; ColourFormat = format; }
public CVImageAttributes(TColourFormat c, int w, int h) { ColourFormat = c; FSize.Width = w; FSize.Height = h; }
public CVImageAttributes(TColourFormat c, int w, int h) { ColourFormat = c; FSize.Width = w; FSize.Height = h; }
public static TChannelFormat ChannelFormat(TColourFormat format) { switch(format) { case TColourFormat.L8: case TColourFormat.RGB8: case TColourFormat.RGBA8: return TChannelFormat.Byte; case TColourFormat.L16: return TChannelFormat.UShort; case TColourFormat.L32F: case TColourFormat.RGB32F: case TColourFormat.RGBA32F: return TChannelFormat.Float; default: throw (new Exception("We haven't implemented ChannelFormat for this TColourFormat")); } }
public CVImageAttributes(Size size, TColourFormat format) { FSize = size; ColourFormat = format; }
public CVImageAttributes() { ColourFormat = TColourFormat.UnInitialised; FSize = new Size(0, 0); }