Question

I have a picture, and I get every pixels and multiply the RGB for a number. I also need to take care when R * number > 255. When this happen, r = 255. It's taking about 10s+ to complete a 1024x768 image. The common softwares that do brightness, takes less than 1s to do it. Any ideias to improve my strategy? Thanks.

Was it helpful?

Solution

I had a similar problem:

How to use ColorMatrix in .NET to change Brightness, Color, Saturation, Hue

For brightness alone, colormatrix will work fine. If you want to start using contrast, etc, you will need to use some other solution. It seems to be SetPixel is the slowest part. See this solution for doing this quickly:

http://www.codeproject.com/KB/GDI-plus/csharpgraphicfilters11.aspx

OTHER TIPS

Using a ColorMatrix would probably be the best way to go. Here's an article to get you on your way: http://www.c-sharpcorner.com/UploadFile/mahesh/Transformations0512192005050129AM/Transformations05.aspx

when I did some simple image manipulation on multi megabyte images I significantly improved performance using unsafe code and pointer manipulation to get at the to the raw bytes.

This might get you in the right direction http://wcode.net/2009/08/unsafe-in-c-and-image-processing/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top