public static uint BytesPerPixel(TColorFormat format) { switch (format) { case TColorFormat.L8: return(1); case TColorFormat.L16: return(2); case TColorFormat.L32F: return(4); case TColorFormat.RGB8: return(3); case TColorFormat.RGB32F: return(3 * sizeof(float)); case TColorFormat.RGBA8: return(4); case TColorFormat.RGBA32F: return(4 * sizeof(float)); default: throw(new NotImplementedException("We haven't implemented BytesPerPixel for this type")); } }
public void GetImage(TColorFormat format, CVImage target) { if (format == this.NativeFormat) ImageUtils.CopyImage(this, target); else ImageUtils.CopyImageConverted(this, target); }
public static string AsString(TColorFormat format) { switch (format) { case TColorFormat.L8: return("L8"); case TColorFormat.L16: return("L16"); case TColorFormat.RGB8: return("RGB8"); case TColorFormat.RGB32F: return("RGB32F"); case TColorFormat.RGBA8: return("RGBA8"); case TColorFormat.RGBA32F: return("RGBA32F"); default: throw (new NotImplementedException("We haven't implemented AsString for this type")); } }
public static int ChannelCount(TColorFormat format) { switch (format) { case TColorFormat.L8: return(1); case TColorFormat.L16: return(1); case TColorFormat.RGB8: return(3); case TColorFormat.RGB32F: return(3); case TColorFormat.RGBA8: return(4); case TColorFormat.RGBA32F: return(4); default: return(0); } }
public static IImage CreateImage(int width, int height, TColorFormat format) { switch (format) { case TColorFormat.L8: return(new Image <Gray, byte>(width, height)); case TColorFormat.L16: return(new Image <Gray, ushort>(width, height)); case TColorFormat.L32S: return(new Image <Gray, int>(width, height)); case TColorFormat.L32F: return(new Image <Gray, float>(width, height)); case TColorFormat.RGB8: return(new Image <Rgb, byte>(width, height)); case TColorFormat.RGB32F: return(new Image <Rgb, float>(width, height)); case TColorFormat.RGBA8: return(new Image <Rgba, byte>(width, height)); case TColorFormat.RGBA32F: return(new Image <Rgba, float>(width, height)); } throw (new NotImplementedException("We have not implemented the automatic creation of this image type")); }
public static IImage CreateImage(int width, int height, TColorFormat format) { switch(format) { case TColorFormat.L8: return new Image<Gray, byte>(width, height); case TColorFormat.L16: return new Image<Gray, ushort>(width, height); case TColorFormat.L32S: return new Image<Gray, int>(width, height); case TColorFormat.L32F: return new Image<Gray, float>(width, height); case TColorFormat.RGB8: return new Image<Rgb, byte>(width, height); case TColorFormat.RGB32F: return new Image<Rgb, float>(width, height); case TColorFormat.RGBA8: return new Image<Rgba, byte>(width, height); case TColorFormat.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(TColorFormat src, TColorFormat dst) { switch (src) { case TColorFormat.L8: switch (dst) { case TColorFormat.RGBA8: return COLOR_CONVERSION.CV_GRAY2RGBA; } break; case TColorFormat.RGB8: switch (dst) { case TColorFormat.L8: return COLOR_CONVERSION.CV_RGB2GRAY; case TColorFormat.RGBA8: return COLOR_CONVERSION.CV_RGB2RGBA; } break; case TColorFormat.RGBA8: switch (dst) { case TColorFormat.L8: return COLOR_CONVERSION.CV_RGBA2GRAY; } break; case TColorFormat.RGB32F: switch (dst) { case TColorFormat.L32F: return COLOR_CONVERSION.CV_RGBA2GRAY; case TColorFormat.RGBA32F: return COLOR_CONVERSION.CV_RGB2RGBA; } break; case TColorFormat.HSV8: switch (dst) { case TColorFormat.RGB8: return COLOR_CONVERSION.CV_HSV2RGB; } break; case TColorFormat.HSV32F: switch (dst) { case TColorFormat.RGB32F: return COLOR_CONVERSION.CV_HSV2RGB; } break; } return COLOR_CONVERSION.CV_COLORCVT_MAX; }
public static COLOR_CONVERSION ConvertRoute(TColorFormat src, TColorFormat dst) { switch (src) { case TColorFormat.L8: { switch (dst) { case TColorFormat.RGBA8: return COLOR_CONVERSION.CV_GRAY2RGBA; } break; } case TColorFormat.RGB8: { switch (dst) { case TColorFormat.L8: return COLOR_CONVERSION.CV_RGB2GRAY; case TColorFormat.RGBA8: return COLOR_CONVERSION.CV_RGB2RGBA; } break; } } return COLOR_CONVERSION.CV_COLORCVT_MAX; }
public static SlimDX.DXGI.Format GetFormat(TColorFormat format) { switch (format) { case TColorFormat.L8: return(SlimDX.DXGI.Format.R8_UNorm); case TColorFormat.L16: return(SlimDX.DXGI.Format.R16_UNorm); case TColorFormat.L32F: return(SlimDX.DXGI.Format.R32_Float); case TColorFormat.RGBA8: return(SlimDX.DXGI.Format.B8G8R8A8_UNorm); case TColorFormat.RGB32F: return(SlimDX.DXGI.Format.R32G32B32_Float); case TColorFormat.RGBA32F: return(SlimDX.DXGI.Format.R32G32B32A32_Float); default: throw (new Exception("Image type not supported by DX11 texture")); } }
public override void Allocate() { FOutFormat = ImageUtils.MakeGrayscale(FInput.ImageAttributes.ColorFormat); //if we can't convert or it's already grayscale, just pass through if (FOutFormat == TColorFormat.UnInitialised) FOutFormat = FInput.ImageAttributes.ColorFormat; FOutput.Image.Initialise(FInput.Image.ImageAttributes.Size, FOutFormat); }
public void GetImage(TColorFormat format, CVImage target) { if (format == this.NativeFormat) { ImageUtils.CopyImage(this, target); } else { ImageUtils.CopyImageConverted(this, target); } }
public static COLOR_CONVERSION ConvertRoute(TColorFormat src, TColorFormat dst) { switch (src) { case TColorFormat.L8: { switch (dst) { case TColorFormat.RGBA8: return(COLOR_CONVERSION.CV_GRAY2RGBA); } break; } case TColorFormat.RGB8: { switch (dst) { case TColorFormat.L8: return(COLOR_CONVERSION.CV_RGB2GRAY); case TColorFormat.RGBA8: return(COLOR_CONVERSION.CV_RGB2RGBA); } break; } case TColorFormat.RGBA8: { switch (dst) { case TColorFormat.L8: return(COLOR_CONVERSION.CV_RGBA2GRAY); } break; } case TColorFormat.RGB32F: { switch (dst) { case TColorFormat.L32F: return(COLOR_CONVERSION.CV_RGBA2GRAY); case TColorFormat.RGBA32F: return(COLOR_CONVERSION.CV_RGB2RGBA); } break; } } return(COLOR_CONVERSION.CV_COLORCVT_MAX); }
public override void Allocate() { FOutFormat = ImageUtils.MakeGrayscale(FInput.ImageAttributes.ColourFormat); //if we can't convert or it's already grayscale, just pass through if (FOutFormat == TColorFormat.UnInitialised) { FOutFormat = FInput.ImageAttributes.ColourFormat; } FOutput.Image.Initialise(FInput.Image.ImageAttributes.Size, FOutFormat); }
public bool Initialise(System.Drawing.Size size, TColorFormat format) { bool changedAttributes = FImageAttributes.CheckChanges(format, size); if (changedAttributes || this.Allocated == false) { Allocate(); return true; } else return false; }
public override void Allocate() { TColorFormat AsGrayscale = TypeUtils.ToGrayscale(FInput.ImageAttributes.ColourFormat); FNeedsConversion = (AsGrayscale != FInput.ImageAttributes.ColourFormat); if (FNeedsConversion) { FGrayscale.Initialise(FInput.ImageAttributes.Size, AsGrayscale); } FOutput.Image.Initialise(FGrayscale.ImageAttributes); }
public static unsafe Spread <double> GetPixelAsDoubles(CVImage source, uint column, uint row) { TColorFormat 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 bool Initialise(System.Drawing.Size size, TColorFormat format) { bool changedAttributes = FImageAttributes.CheckChanges(format, size); if (changedAttributes || this.Allocated == false) { Allocate(); return(true); } else { return(false); } }
public unsafe bool SetImage(IImage source) { if (source == null) { return(false); } TColorFormat sourceFormat = ImageUtils.GetFormat(source); bool Reinitialise = Initialise(source.Size, sourceFormat); ImageUtils.CopyImage(source, this); this.Timestamp = DateTime.UtcNow.Ticks; return(Reinitialise); }
public bool CheckChanges(TColorFormat c, Size s) { bool changed = false; if (c != ColorFormat) { ColorFormat = c; changed = true; } if (s != FSize) { FSize = s; changed = true; } return changed; }
public static Texture CreateTexture(CVImageAttributes attributes, Device device) { TColorFormat format = attributes.ColourFormat; TColorFormat newFormat; bool useConverted = NeedsConversion(format, out newFormat); try { return(new Texture(device, Math.Max(attributes.Width, 1), Math.Max(attributes.Height, 1), 1, Usage.None, GetDXFormat(useConverted ? newFormat : format), Pool.Managed)); } catch (Exception e) { ImageUtils.Log(e); return(new Texture(device, 1, 1, 1, Usage.None, Format.X8R8G8B8, Pool.Managed)); } }
public bool CheckChanges(TColorFormat c, Size s) { bool changed = false; if (c != ColorFormat) { ColorFormat = c; changed = true; } if (s != FSize) { FSize = s; changed = true; } return(changed); }
public static bool NeedsConversion(TColorFormat format, out TColorFormat targetFormat) { switch (format) { case TColorFormat.RGB8: targetFormat = TColorFormat.RGBA8; return(true); case TColorFormat.RGB32F: targetFormat = TColorFormat.RGBA32F; return(true); default: targetFormat = TColorFormat.UnInitialised; return(false); } }
private void configureOutput() { // memory reallocation int[] memList; camStatus = cam.Memory.GetList(out memList); camStatus = cam.Memory.Free(memList); camStatus = cam.Memory.Allocate(); uEye.Defines.ColorMode pixFormat; camStatus = cam.PixelFormat.Get(out pixFormat); TColorFormat format = GetColor(pixFormat); Rectangle a; camStatus = cam.Size.AOI.Get(out a); FOutput.Image.Initialise(a.Width, a.Height, format); }
public static TColorFormat MakeGrayscale(TColorFormat format) { switch (format) { case TColorFormat.RGB8: return(TColorFormat.L8); case TColorFormat.RGB32F: return(TColorFormat.L32F); case TColorFormat.RGBA8: return(TColorFormat.L8); case TColorFormat.RGBA32F: return(TColorFormat.L32F); default: return(TColorFormat.UnInitialised); } }
public static SlimDX.DXGI.Format GetFormat(TColorFormat format) { switch (format) { case TColorFormat.L8: return SlimDX.DXGI.Format.R8_UNorm; case TColorFormat.L16 : return SlimDX.DXGI.Format.R16_UNorm; case TColorFormat.L32F: return SlimDX.DXGI.Format.R32_Float; case TColorFormat.RGBA8: return SlimDX.DXGI.Format.B8G8R8A8_UNorm; case TColorFormat.RGB32F: return SlimDX.DXGI.Format.R32G32B32_Float; case TColorFormat.RGBA32F: return SlimDX.DXGI.Format.R32G32B32A32_Float; default: throw (new Exception("Image type not supported by DX11 texture")); } }
public static TChannelFormat ChannelFormat(TColorFormat format) { switch (format) { case TColorFormat.L8: case TColorFormat.RGB8: case TColorFormat.RGBA8: return(TChannelFormat.Byte); case TColorFormat.L16: return(TChannelFormat.UShort); case TColorFormat.L32F: case TColorFormat.RGB32F: case TColorFormat.RGBA32F: return(TChannelFormat.Float); default: throw (new Exception("We haven't implemented ChannelFormat for this TColorFormat")); } }
public static TColorFormat ToGrayscale(TColorFormat Format) { switch (Format) { case TColorFormat.RGBA32F: case TColorFormat.RGB32F: case TColorFormat.L32F: return(TColorFormat.L32F); case TColorFormat.L32S: return(TColorFormat.L32S); case TColorFormat.L16: return(TColorFormat.L16); case TColorFormat.RGBA8: case TColorFormat.RGB8: case TColorFormat.L8: return(TColorFormat.L8); } throw (new Exception("ToGrayscale does not support format " + Format.ToString())); }
private void cboColors_SelectedIndexChanged(object sender, EventArgs e) { switch (cboColors.SelectedIndex) { case 0: m_colfrmt = TColorFormat.RGB; break; case 1: m_colfrmt = TColorFormat.RGB_F; break; case 2: m_colfrmt = TColorFormat.HEX; break; case 3: m_colfrmt = TColorFormat.WEB; break; case 4: m_colfrmt = TColorFormat.CSHARP; break; case 5: m_colfrmt = TColorFormat.VB; break; case 6: m_colfrmt = TColorFormat.VBLong; break; case 7: m_colfrmt = TColorFormat.CPLUS; break; } SetColorFrmt(hsbRed.Value, hsbGreen.Value, hsbBlue.Value); }
public static TColorFormat ToGrayscale(TColorFormat Format) { switch (Format) { case TColorFormat.RGBA32F: case TColorFormat.RGB32F: case TColorFormat.L32F: return TColorFormat.L32F; case TColorFormat.L32S: return TColorFormat.L32S; case TColorFormat.L16: return TColorFormat.L16; case TColorFormat.RGBA8: case TColorFormat.RGB8: case TColorFormat.L8: return TColorFormat.L8; } throw (new Exception("ToGrayscale does not support format " + Format.ToString())); }
public static Format GetDXFormat(TColorFormat format) { switch (format) { case TColorFormat.L8: return(Format.L8); case TColorFormat.L16: return(Format.L16); case TColorFormat.L32F: return(Format.R32F); case TColorFormat.RGBA32F: return(Format.A32B32G32R32F); case TColorFormat.RGBA8: return(Format.A8R8G8B8); default: throw (new NotImplementedException("Cannot create a texture to match Image's format")); } }
public bool SetImage(Bitmap source) { if (source == null) { return(false); } TColorFormat format = ImageUtils.GetFormat(source.PixelFormat); if (format == TColorFormat.UnInitialised) { return(false); } bool Reinitialise = Initialise(source.Size, format); var bitmapData = source.LockBits(new Rectangle(0, 0, source.Width, source.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, source.PixelFormat); ImageUtils.CopyImage(bitmapData.Scan0, this); source.UnlockBits(bitmapData); this.Timestamp = DateTime.UtcNow.Ticks; return(Reinitialise); }
public static TColorFormat MakeGrayscale(TColorFormat format) { switch (format) { case TColorFormat.RGB8: return TColorFormat.L8; case TColorFormat.RGB32F: return TColorFormat.L32F; case TColorFormat.RGBA8: return TColorFormat.L8; case TColorFormat.RGBA32F: return TColorFormat.L32F; default: return TColorFormat.UnInitialised; } }
public static int ChannelCount(TColorFormat format) { switch (format) { case TColorFormat.L8: return 1; case TColorFormat.L16: return 1; case TColorFormat.RGB8: return 3; case TColorFormat.RGB32F: return 3; case TColorFormat.RGBA8: return 4; case TColorFormat.RGBA32F: return 4; default: return 0; } }
public static uint BytesPerPixel(TColorFormat format) { switch (format) { case TColorFormat.L8: return 1; case TColorFormat.L16: return 2; case TColorFormat.L32F: return 4; case TColorFormat.RGB8: return 3; case TColorFormat.RGB32F: return 3 * sizeof(float); case TColorFormat.RGBA8: return 4; case TColorFormat.RGBA32F: return 4 * sizeof(float); default: throw(new NotImplementedException("We haven't implemented BytesPerPixel for this type")); } }
public CVImageAttributes() { ColorFormat = TColorFormat.UnInitialised; FSize = new Size(0, 0); }
public static string AsString(TColorFormat format) { switch (format) { case TColorFormat.L8: return "L8"; case TColorFormat.L16: return "L16"; case TColorFormat.RGB8: return "RGB8"; case TColorFormat.RGB32F: return "RGB32F"; case TColorFormat.RGBA8: return "RGBA8"; case TColorFormat.RGBA32F: return "RGBA32F"; default: throw (new NotImplementedException("We haven't implemented AsString for this type")); } }
public CVImageAttributes(TColorFormat c, int w, int h) { ColorFormat = c; FSize.Width = w; FSize.Height = h; }
public bool Initialise(int Width, int Height, TColorFormat Format) { return(this.Initialise(new System.Drawing.Size(Width, Height), Format)); }
public bool Initialise(int Width, int Height, TColorFormat Format) { return this.Initialise(new System.Drawing.Size(Width, Height), Format); }
public static TChannelFormat ChannelFormat(TColorFormat format) { switch(format) { case TColorFormat.L8: case TColorFormat.RGB8: case TColorFormat.RGBA8: return TChannelFormat.Byte; case TColorFormat.L16: return TChannelFormat.UShort; case TColorFormat.L32F: case TColorFormat.RGB32F: case TColorFormat.RGBA32F: return TChannelFormat.Float; default: throw (new Exception("We haven't implemented ChannelFormat for this TColorFormat")); } }
public static Format GetDXFormat(TColorFormat format) { switch (format) { case TColorFormat.L8: return Format.L8; case TColorFormat.L16: return Format.L16; case TColorFormat.L32F: return Format.R32F; case TColorFormat.RGBA32F: return Format.A32B32G32R32F; case TColorFormat.RGBA8: return Format.A8R8G8B8; default: throw (new NotImplementedException("Cannot create a texture to match Image's format")); } }
public CVImageAttributes(Size size, TColorFormat format) { FSize = size; ColorFormat = format; }
public static bool NeedsConversion(TColorFormat format, out TColorFormat targetFormat) { switch(format) { case TColorFormat.RGB8: targetFormat = TColorFormat.RGBA8; return true; case TColorFormat.RGB32F: targetFormat = TColorFormat.RGBA32F; return true; default: targetFormat = TColorFormat.UnInitialised; return false; } }