[Closed] Dotnet Image manipulation?
I’m looking for ways to deal with color correction, saturation, value, that sort of thing. Having a hard to trying to find methods that will help me with this. Any one have any suggestions on where I should be looking?
Hi there! my knowing about scripting is really small, but may be this could help.
Theres a composite map with those handlers (hue,saturation,contrast, etc). May be
you can use that for CC controls and then extract the results.
Hope it helps
Thanks, I’m aware of the composite map, I’m looking at doing this in memory only. I think that the only way to get the result of the composite map would be to render it as well.
firstly, Pete has some examples on his site that will likely be of interest to you. Direct Link Here
other than that, the best (fastest) way would be a C# / VB.NET solution either using an existing library or you can write your own methods / classes. there are a few decent open source libraries out there. off the top of my head I think AForge was a good one and also MagickNet and there are probably a few other ones that I’m forgetting.
If you’re going to write your own, there’s a series of about 5 or so articles on codeproject called ‘Image Processing for Dummies’ which provides complete working C# code and explanations on how to perform certain effects yourself. The first article can be found HERE and covers Invert, GrayScale, Brightness, Contrast, Gamma and Color filters / effects.
the slowest possible option would be writing your own image processing functions in maxscript, using GetPixel on the image, processing the pixel/dnColor and then using SetPixel to apply it.
This is what was afraid of, I didn’t want to have to supply any other external files with this. I’m not doing big images so I will test the speed of the get/set pixel as I was already looking at that. Might just not be worth it and I don’t have time to start compiling new dlls for it. Thanks for the insight.
actually you might be able to get away with using the ColorMatrix class in maxscript to achieve what you want just as Pete has on his site. I thought he was using the ColorMatrix class in his own dlls but it looks like it’s mostly maxscript. I’m not sure where the download link has gone but the maxscript he (previously) provided looks like the kind of thing you are after
Hi,
If you decide to go the maxscript route, you should check out pasteBitmap instead of get/setPixels. It’s a lot faster and can be used with a function to do the calculation.
As for dotNet, if you don’t want to supply additional files, you could incorporate the c# (or whatever .net language) code in the script as text, and compile the assembly at runtime. This is a bit messy but works fine, and if the assembly code is not very long, it should compile in not more than a couple of seconds (and only needs to be done once per max session). See this thread ( http://forums.cgsociety.org/showthread.php?t=721132 ) for some discussion and code.
Cheers,
o
Good point on the jit compile. I’ll look at the colorMatrix, I have seen that but couldn’t sort out how to work with it.
I should also point out that the get/set pixel method is no good at all. It takes forever.
I looked up the thread by Ofer that Pete refers to and it helped me get the understanding of how to pass the values correctly for the colorMatrix using straight Max script. This appears to work fast enough for what I need. Just need to try and sort how to manipulate the values of the color matrix. Still not sure what it is all doing. I’ll report back when I have something solid sorted out.
Hi Paul,
How are you? Sorry for not wading in earlier on this, Have been a bit of a coding and CGtalk hermit for a while.
I hadn’t realised that LR.net is in such a sorry state. The blog format has somehow mashed a lot of my code postings. I will try to rectify this and get out of my cupboard in the next few days.
I have updated the post’s download link with the full MXS code for using the adjustment color matrices. (it should be pretty well commented) You wont have to use the dlls supplied for the color correction, they are just for the utility pictured at the start.
Thanks Pete, I ran your code and noticed that the saturation slider doesn’t really work. In PS for instance if you pull it down to -100 you get a gray scale image, in yours it gets some strange results. Is this what you intended?
I’m just starting to write a function for multiplying the colorMatrix values so that I can get the expected results. I don’t know if there is an easier way at this point but I have not found anything on the web that is giving me anything to go on.