public MosaicForm() { InitializeComponent(); uniformSampler = new UniformImageSampler() { Progress = samplingProgress }; gaussianSampler = new GaussianImageSampler() { Progress = samplingProgress }; hybridGaussianSampler = new HybridGaussianImageSampler() { Progress = samplingProgress, ClusterCount = 10 }; voronoiVisualizer = new VoronoiVisualizer(reconstructionProgress); pointVisualizer = new PointVisualizer(reconstructionProgress); visualizer = voronoiVisualizer; imageSampler = uniformSampler; SetVoronoiVisualizerOptions(); this.samplerTypeComboBox.DataSource = System.Enum.GetValues(typeof(ImageSamplerType)); this.imageVisualizerComboBox.DataSource = System.Enum.GetValues(typeof(VisualizerType)); samplerTypeComboBox.SelectedIndex = 0; imageVisualizerComboBox.SelectedIndex = 0; samplingProgress.ProgressChanged += ReportProgress; reconstructionProgress.ProgressChanged += ReportProgress; }
public ImageSamplerData(IImageSampler sampler) { MinFilter = sampler.MinFilter; MagFilter = sampler.MagFilter; MipFilter = sampler.MipFilter; AddressModeU = sampler.AddressModeU; AddressModeV = sampler.AddressModeV; AddressModeW = sampler.AddressModeW; MaxAnisotropy = sampler.MaxAnisotropy; }
private ISampler CreateGlSampler(IImageSampler cSampler) { var glSampler = glContext.Create.Sampler(); glSampler.SetMagFilter(cSampler.MagFilter.ToOglMag()); glSampler.SetMinFilter(Converters.ToOglMin(cSampler.MinFilter, cSampler.MipFilter)); glSampler.SetWrapR(cSampler.AddressModeU.ToOgl()); glSampler.SetWrapS(cSampler.AddressModeV.ToOgl()); glSampler.SetWrapT(cSampler.AddressModeW.ToOgl()); glSampler.SetMaxAnisotropy(cSampler.MaxAnisotropy); return(glSampler); }
public StandardMaterialData(IStandardMaterial material) { DiffuseColor = material.DiffuseColor; DiffuseMap = material.DiffuseMap; NormalMap = material.NormalMap; Sampler = material.Sampler; IgnoreLighting = material.IgnoreLighting; NoSpecular = material.NoSpecular; HasTransparency = material.HasTransparency; HighlightEffect = material.HighlightEffect; RtTransparencyMode = material.RtTransparencyMode; }
public static Image Resize(this Image source, int width, int height, StretchMode mode = StretchMode.Fill, IImageSampler sampler = null) { if (mode != StretchMode.Fill) throw new NotImplementedException(); if (width <= 0) throw new ArgumentOutOfRangeException(nameof(width)); if (height <= 0) throw new ArgumentOutOfRangeException(nameof(height)); if (width > Image.MaxWidth || width > Image.MaxHeight) { throw new ArgumentOutOfRangeException( $"Target size '{ width }x{ width }' is bigger then the max allowed size '{ Image.MaxWidth }x{ Image.MaxHeight }'"); } sampler = sampler ?? defaultSampler; return PerformAction(source, image => sampler.Sample(image, width, height)); }
public static Image Resize(this Image source, int size, StretchMode mode = StretchMode.Fill, IImageSampler sampler = null) { int width = 0; int height = 0; var ratio = source.AspectRatio; if (source.Width > source.Height && ratio > 0) { width = size; height = (int)Math.Round(width / ratio); } else { height = size; width = (int)Math.Round(height * ratio); } return Resize(source, width, height, mode, sampler); }
public void resize_image_using_sampler(string filename, int width, int? height, StretchMode mode, IImageSampler sampler) { var image = Image.Load($"TestImages/{ filename }"); var watch = Stopwatch.StartNew(); if (height != null) { image = image.Resize(width, height.Value, mode, sampler); } else { image = image.Resize(width, mode, sampler); } Trace.WriteLine($"{ sampler.GetType().Name }: { watch.ElapsedMilliseconds}ms"); height = height ?? width; var outputFile = $"TestResult/Resized/{ Path.GetFileNameWithoutExtension(filename) }.{ mode }.{ sampler.GetType().Name }.{ width }x{ height }.jpg"; image.VerifyAndSave(outputFile); }
public static Image Width(this Image source, int width, int height = -1, StretchMode mode = StretchMode.Fill, IImageSampler sampler = null) => Resize(source, width, height >= 0 ? height : (int)Math.Round(width / source.AspectRatio), mode, sampler);
private void samplerTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { switch ((ImageSamplerType)samplerTypeComboBox.SelectedValue) { case ImageSamplerType.Uniform: imageSampler = uniformSampler; samplingClusterCountNumeric.Enabled = false; break; case ImageSamplerType.Gaussian: imageSampler = gaussianSampler; samplingClusterCountNumeric.Enabled = false; break; case ImageSamplerType.HybridGaussianUniform: imageSampler = hybridGaussianSampler; samplingClusterCountNumeric.Enabled = true; break; default: throw new NotImplementedException(); } }
public ISampler GetGlSampler(IImageSampler cSampler) => dict.GetOrAdd(cSampler, CreateGlSampler);
public ImageBuilder(IImageSampler sampler, IPixelConverter converter, Color transparencyColor) { _sampler = sampler; _converter = converter; _transparencyColor = transparencyColor; }
public void Dispose() { if (_bmp != null) { _bmp.Dispose(); _bmp = null; _frameDimension = null; _sampler = null; _converter = null; } }
public ImageBufferBuilder(Bitmap bmp, Size size, IImageSampler sampler, IPixelConverter converter, Color transparencyColor) { _bmp = bmp; _size = size; _sampler = sampler; _converter = converter; _transparencyColor = transparencyColor; _frameDimension = new FrameDimension(bmp.FrameDimensionsList[0]); _frameCount = bmp.GetFrameCount(_frameDimension); }
public static Image Resize(this Image source, int width, int height, StretchMode mode = StretchMode.Fill, IImageSampler sampler = null) { if (mode != StretchMode.Fill) { throw new NotImplementedException(); } if (width <= 0) { throw new ArgumentOutOfRangeException(nameof(width)); } if (height <= 0) { throw new ArgumentOutOfRangeException(nameof(height)); } if (width > Image.MaxWidth || width > Image.MaxHeight) { throw new ArgumentOutOfRangeException( $"Target size '{ width }x{ width }' is bigger then the max allowed size '{ Image.MaxWidth }x{ Image.MaxHeight }'"); } sampler = sampler ?? defaultSampler; return(PerformAction(source, image => sampler.Sample(image, width, height))); }
/// <summary> /// Applies the collection of processors to the image. /// <remarks> /// This method does will resize the target image if the source and target rectangles are different. /// </remarks> /// </summary> /// <typeparam name="T">The pixel format.</typeparam> /// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam> /// <param name="source">The source image. Cannot be null.</param> /// <param name="width">The target image width.</param> /// <param name="height">The target image height.</param> /// <param name="sourceRectangle"> /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw. /// </param> /// <param name="targetRectangle"> /// The <see cref="Rectangle"/> structure that specifies the location and size of the drawn image. /// The image is scaled to fit the rectangle. /// </param> /// <param name="sampler">The processor to apply to the image.</param> /// <returns>The <see cref="Image{T, TP}"/>.</returns> internal static Image <T, TP> Process <T, TP>(this Image <T, TP> source, int width, int height, Rectangle sourceRectangle, Rectangle targetRectangle, IImageSampler <T, TP> sampler) where T : IPackedVector <TP> where TP : struct { return(PerformAction(source, false, (sourceImage, targetImage) => sampler.Apply(targetImage, sourceImage, width, height, targetRectangle, sourceRectangle))); }
/// <summary> /// Applies the processor to the image. /// <remarks>This method does not resize the target image.</remarks> /// </summary> /// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam> /// <param name="source">The image this method extends.</param> /// <param name="sourceRectangle"> /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw. /// </param> /// <param name="processor">The processors to apply to the image.</param> /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns> internal static Image <TColor, TPacked> Process <TColor, TPacked>(this Image <TColor, TPacked> source, Rectangle sourceRectangle, IImageSampler <TColor, TPacked> processor) where TColor : struct, IPackedPixel <TPacked> where TPacked : struct { return(PerformAction(source, true, (sourceImage, targetImage) => processor.Apply(targetImage, sourceImage, sourceRectangle))); }
/// <summary> /// Applies the processor to the image. /// <remarks> /// This method does will resize the target image if the source and target rectangles are different. /// </remarks> /// </summary> /// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam> /// <param name="source">The source image. Cannot be null.</param> /// <param name="width">The target image width.</param> /// <param name="height">The target image height.</param> /// <param name="sourceRectangle"> /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw. /// </param> /// <param name="targetRectangle"> /// The <see cref="Rectangle"/> structure that specifies the location and size of the drawn image. /// The image is scaled to fit the rectangle. /// </param> /// <param name="sampler">The processor to apply to the image.</param> /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns> internal static Image <TColor, TPacked> Process <TColor, TPacked>(this Image <TColor, TPacked> source, int width, int height, Rectangle sourceRectangle, Rectangle targetRectangle, IImageSampler <TColor, TPacked> sampler) where TColor : struct, IPackedPixel <TPacked> where TPacked : struct { return(PerformAction(source, false, (sourceImage, targetImage) => sampler.Apply(targetImage, sourceImage, width, height, targetRectangle, sourceRectangle))); }
private static SampledImage SampleImage(IImageSampler sampler) { Bitmap image = (Bitmap)Bitmap.FromFile(DATA_DIR + INPUT_IMAGE); return sampler.SampleImage(image, SAMPLE_COUNT); }
public static Image Height(this Image source, int height, int width = -1, StretchMode mode = StretchMode.Fill, IImageSampler sampler = null) => Resize(source, width >= 0 ? width : (int)Math.Round(height * source.AspectRatio), height, mode, sampler);
public RendrerBase(IImageSampler imageSampler) { m_imageSampler = imageSampler; }
public void resize_image_using_sampler(string filename, int width, int?height, StretchMode mode, IImageSampler sampler) { var image = Image.Load($"TestImages/{ filename }"); var watch = Stopwatch.StartNew(); if (height != null) { image = image.Resize(width, height.Value, mode, sampler); } else { image = image.Resize(width, mode, sampler); } Trace.WriteLine($"{ sampler.GetType().Name }: { watch.ElapsedMilliseconds}ms"); height = height ?? width; var outputFile = $"TestResult/Resized/{ Path.GetFileNameWithoutExtension(filename) }.{ mode }.{ sampler.GetType().Name }.{ width }x{ height }.jpg"; image.VerifyAndSave(outputFile); }
/// <summary> /// Applies the processor to the image. /// <remarks>This method does not resize the target image.</remarks> /// </summary> /// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam> /// <param name="source">The image this method extends.</param> /// <param name="processor">The processor to apply to the image.</param> /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns> internal static Image <TColor, TPacked> Process <TColor, TPacked>(this Image <TColor, TPacked> source, IImageSampler <TColor, TPacked> processor) where TColor : struct, IPackedPixel <TPacked> where TPacked : struct { return(Process(source, source.Bounds, processor)); }
public static Image Resize(this Image source, int size, StretchMode mode = StretchMode.Fill, IImageSampler sampler = null) { int width = 0; int height = 0; var ratio = source.AspectRatio; if (source.Width > source.Height && ratio > 0) { width = size; height = (int)Math.Round(width / ratio); } else { height = size; width = (int)Math.Round(height * ratio); } return(Resize(source, width, height, mode, sampler)); }
/// <summary> /// Applies the processor to the image. /// <remarks> /// This method resizes the image. /// </remarks> /// </summary> /// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TPacked">The packed format. <example>long, float.</example></typeparam> /// <param name="source">The source image. Cannot be null.</param> /// <param name="width">The target image width.</param> /// <param name="height">The target image height.</param> /// <param name="sampler">The processor to apply to the image.</param> /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns> internal static Image <TColor, TPacked> Process <TColor, TPacked>(this Image <TColor, TPacked> source, int width, int height, IImageSampler <TColor, TPacked> sampler) where TColor : struct, IPackedPixel <TPacked> where TPacked : struct { return(Process(source, width, height, source.Bounds, default(Rectangle), sampler)); }
/// <summary> /// Applies the collection of processors to the image. /// <remarks> /// This method is not chainable. /// </remarks> /// </summary> /// <typeparam name="T">The pixel format.</typeparam> /// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam> /// <param name="source">The source image. Cannot be null.</param> /// <param name="width">The target image width.</param> /// <param name="height">The target image height.</param> /// <param name="sampler">The processor to apply to the image.</param> /// <returns>The <see cref="Image{T, TP}"/>.</returns> internal static Image <T, TP> Process <T, TP>(this Image <T, TP> source, int width, int height, IImageSampler <T, TP> sampler) where T : IPackedVector <TP> where TP : struct { return(Process(source, width, height, source.Bounds, default(Rectangle), sampler)); }