![]() |
c#mat2gray(matlab)函数
有人知道c#的图像处理库具有与matlab中的[URL="http://www.mathworks.com/help/toolbox/images/ref/mat2gray.html"]mat2gray[/URL]函数类似的功能吗?
谢谢。 [B]回答:[/B] 就像是: 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的东西需要一些微调 [url=https://stackoverflow.com/questions/5418171]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 00:13。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.