Hi ~
I need to make some image processing feature in my application, i use the classes in the namespaces of System.Drawing. The function i need to implemenet is the image filter, that is need to create a matrix to convoloving every pixel of the image. When i use the classes in the System.Drawing e.g. Bitmap.SetPixel or Bitmap.GetPixel, i found that the performance is not good. Such as i convoloving the 640*480 image, it take about 1.5 mins to complete. I see the commerical software like photoshop can process much faster. Is it the classes in System.Drawing have not well performance, or it is better to use another graphics toolkit from third party ?
Thank :)
Loading
BrettPosted Mar 9, 2007, 12:36 AM
GetPixel and SetPixel are just too slow to do image processing. There's a way around this if you don't mind writing a little 'unsafe' code. This is explained in the first link on Bob Powells site...
http://www.bobpowell.net/imageprocessing.htm
It also explains what 'unsafe' code is. If you don't want to use 'unsafe' code, maybe copying the image into a 2d array using GetPixel/SetPixel, then doing the convolution on the array and then copying it back to the image would be faster. It's getting the data in and out of the image class that takes the time. Convolving a 640x480 array with a 3x3 array is an eye blink in C++ using ptr to array of ptrs. It's probably pretty fast in C# too using 2d arrays or jagged arrays. It's the GetPixel and SetPixel part that is slow.
Good luck, Brett.