c# - 如何将高斯高通内核显示为位图?
问题描述
如何将高斯高通内核转换为位图图像以供显示?
我尝试了以下功能:
双倍整数:
public static Bitmap ToBitmap(Array2d<double> image, PixelFormat pixelFormat) { Array2d<double> imageCopy = image.Copy(); int Width = imageCopy.Width; int Height = imageCopy.Height; Bitmap bitmap = new Bitmap(Width, Height, pixelFormat); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { double d = imageCopy[x, y]; int iii = Convert.ToInt32(d*255.0); Color clr = Color.FromArgb(iii, iii, iii); bitmap.SetPixel(x, y, clr); } } return bitmap; }
日志拉伸:
public static Array2d<double> Stretch(Array2d<double> data) { int Width = data.Width; int Height = data.Height; Array2d<double> array2d = new Array2d<double>(Width, Height); for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { array2d[i, j] = Math.Log(data[i, j] + 1); } } return array2d; }
他们似乎都没有工作,因为他们给出了以下例外:
System.Drawing.dll 中出现“System.ArgumentException”类型的未处理异常
附加信息:“133028503”的值对“红色”无效。'red' 应大于或等于 0 且小于或等于 255。
以下来自高斯核的样本数据:
有些值太低,有些值太高,无法转换为 0-255 范围内的整数。
解决方案
推荐阅读
- angular - 是否可以在 Angular 中同时将输入绑定到两个变量?
- php - php.exe (WAMP) 不能分配超过 1G 的内存,即使内存 _limit 设置为 -1
- ruby-on-rails - ActiveModel::UnknownAttributeError(Order 的未知属性“order_itens_attributes”。):
- ruby-on-rails - 使用 Rails i18n 生产时,特定的 activerecord 属性会丢失翻译
- amazon-web-services - AWS Route53 域
- android - FusedLocationClient 的 requestLocationUpdates 回调可用
- database - 我在 oracle 数据库中创建表,同时在自动递增 id 表中添加新行,它在前一行之前而不是之后添加行
- php - WP 通过 $_GET 查询 get 和 id 并将其更改为 CPT 链接
- wpf - WPF - 将静态资源分配到 XAML 数组中,无需代码隐藏
- javascript - 三.js 将图像放在摄像头前