开发者

create an rgb image from a 3-D double array

i have a 672*472*3 size array of type double(r-g-b channels of an image). the values at each pixel position range from 0.000 to 5.0000. i n开发者_StackOverflow社区eed to show the data as an image on a picturebox. how can i do this in c#.


You could create a new Bitmap object and set the pixels according to the data in your array with SetPixel()

See here:

http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.setpixel.aspx

You will have to iterate over the array with two loops and translate the 0-5 range to 0-255 to create a color object.

Then you can simply assign the Bitmap to the Image-Property of the PictureBox.

Is this specific enough?

EDIT:

You can convert your doubles with the range of 0.0000 to 0.5000 by the simply dividing by five and multiplying with 255 for each component. e.g.

bmpBitmap.SetPixel(iX, iY, 
Color.FromArgb((int)(arArray[iX, iY, 0] / 5 * 255), 
(int)(arArray[iX, iY, 1] / 5 * 255), 
(int)(arArray[iX, iY, 2] / 5 * 255)
);

You will probably have to adjust the array indices.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜