时间:2019-01-17 标签:c#mat2gray(matlab)function

标签 c# matlab image-processing grayscale

任何人都知道 C# 图像处理库,其功能类似于 mat2gray matlab中的函数?

谢谢。

最佳答案

类似于:

public Bitmap mat2gray(int[,] mat,double? amin = null, double? amax = null){

  var sizex = mat.GetLength(0);
  var sizey = mat.GetLength(1);
  if (!amin.HasValue)
    amin = 0;
  if (!amax.HasValue)
    amax = 1;
  var ret = new Bitmap(sizex,sizey);
   for (int i=0; i< sizex;i++){
    for (int j=0; j< sizey;j++){
      int A = (int)((Math.Round(mat[i,j]-amin.Value)*(255.0/amax.Value))%amax.Value);
      ret.SetPixel(i,j,Color.FromArgb(A,A,A));
    }
}

但是 amin/amax 的东西需要一些微调

关于时间:2019-01-17 标签:c#mat2gray(matlab)function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5418171/

相关文章:

c# - C#Youtube API,不触发事件

c# - 在另一个窗体中调用方法 C#

matlab - 使用 "band of uncertainity"显示数据与时间的轨迹

matlab - 每个状态的隐马尔可夫模型多个观察值

MATLAB - 如何(优雅地)对矩阵进行插值?

c# - 如何将软实时数据从 Matlab 流式传输到 C# 应用程序?

c# - 将条件字符串解析为 bool 值

c# - 单声道兼容的 RAW 图像解码器

c# - 从常见图像格式中删除所有元数据?

python - 如何拼接使用广角镜头拍摄的重叠区域较小的图像?