sh0dan // VoxPod

Monday, March 28, 2005

Back again with fresh ideas!

Hi!

Now I'm back again, and have resumed work on the Raw Engine. The two lastest features are Levels and Perspective Correction.

Levels was quite interesting, as gamma doesn't really make much sense in under- or over-exposed areas. That resulted in some funky colors and weird banding on values less than black and more than white. If I min/max'ed the values before applying gamma, it resulted in not-quite-white areas because chrominace wasn't always 0 in these areas. So I had to adjust the shader to only apply gamma in the valid 0 to 1 range, and pass the Luminance straight through otherwise.

Perpective Correction is basicly allowing the user to drag each corner of the image.

I still have some newly introduced problems to look after. Right now the mouse to GUI to texture coordinate mapping is getting rather funny - mostly rotation is making things a bit funky. But I hope to iron out these things tonight. I also b0rked something when implementing ufraw's White Balance presets. Right now the white balance just seems wrong, and colors are a bit off compared to everything else.

Other things have been crossing my mind. Mostly the rather simple task of creating a histogram has been interesting to me. It seems almost inavoidable to me to have to read back a (reduced) version from GPU to memory for a histogram analysis, and uploading a pixel array with the histogram data. Performancewise this is not very desirable, even if this only has to be done when a parameter has been updated, but it seems there is no way around it.

Interpolation is also something I'll have to deal with soon. Rotation and perpective correction requires a better interpolator than bilinear. So my first plan i a bicubic interpolator.



Latest Screenshot.

Friday, March 18, 2005

Easter holiday

I'll be taking a break from my computer for the next week and go skiing for a week with my family. So for the next week there isn't going to be much development done. Hopefully I'll be able to cook up some great ideas while I'm a bit away from my computer.

Tuesday, March 15, 2005

A little something for the eyes

I just got annoyed by the default DirectX icon, so I dug up a nice image by Keith Wilson at Stock Exchange. After a little work in PS this is the result:


The icon for the application in the different sizes.

As for work on the application, I'm doing some cleanup and error handling today. The next task will probably be cropping and after that file saving - most likely using libpng.

Monday, March 14, 2005

More Color Adjustments

So now I got color adjustments done. Brightness, Contrast, Hue and Saturation.

Hue and saturation is done in YUV colorspace, since the RGB->YUV->RGB calculation is a lot faster than RGB->HSV->RGB and the result is the same.

Brightness is a bit interesting, since it's dealing with unclamped values. That means that when brightness is -100%, overexposed areas will still show through. This is one of the niceties of float point arithmetic.

I got a release build working, by disabling Global Optimizations on the problematic routine. Not the ideal solution, as the function is the most critical of them all, since it is the high quality interpolation routine.

Now I'll spare my fingers from further typing tonight, and post the most recent screenshot:

Sunday, March 13, 2005

UI and navigation

I've been working a bit more on the UI, for now this has been done:
  • File Drag 'n' Drop support.
  • Image rotation, with live update.
  • Automatic Image Rotation based on EXIF.
  • Black Level adjustment.
  • Mouse Wheel support for PS-inspired zoom steps.
  • Minor tweaks and adjustments.
I've been fighting for some of these features, since I don't have access to any internet at home, some simple things suddenly become quite complex, when you suddenly miss some basic formula or function call and you can't find anything on your computer.

I've been getting some help som Google Desktop Search, which has been so kind to index my harddrive. Suddently seaching through your entire source code library is a breeze. Very helpful indeed! I also noted that it made a great archivation util, since it indexes all changes I make to my source code on the fly - so now I got 150 snapshots of my main code file already. ;)

Up next is more image adjustments. Levels, brightness, contrast, hue and saturation should be rather straightforward and should be the next part of the project. The next challenge will be image download and saving, but using PNG and JPEG libraries should make the file creation a bit eassier. Anyway here is todays screenshot:

Friday, March 11, 2005

Speed and Framework

I've been working on implementing nice navigation, and so far it looks very good IMHO. Fluid scaling and panning has been put in so far. Easy and intuitive navigation is essential, so that'll be a major part of this application beside speed and high image quality.

Last night, I got simple bilinear Bayer interpolation done in hardware. Now the full-size RAW loads in about a second. I also got basic Exposure and Whitebalance compensation made, so now I'm getting to some of the more interesting feature. Compiling in Release mode is a problem though, since the VC+ 2003 compiler b0rks on the high quality Bayer software interpolation, when Global Optimizations are turned on. Thanks MS!

But mainly I've been doing framework for the application, to ease implementation of the upcoming features. There are still a few hacks in the current design, but it's all shaping up quite nicely.

I'm still considering how many renderpasses to do. Basicly the dilemma is between complex shaders or many offscreen textures. I think graphic card memory limitation will probably determine how many renditions will have to be made, since a 3000x2000 pixel FP16 texture is about 16 megs. Subtract the initial (uploaded) texture and the (double buffered) screen display, and there isn't that many textures that can be done on a 128meg card. Rotation and perspective correction will most likely require a render-to-texture when they are to be implemented, but let's worry about that when it needs to be implemented. So far it just seems sensible to be quite conservative about texture usage.

As a final note, I registered the project at SourceForge, since I'd like to have a CVS repository and somewhere for testers to return feedback when that time arrives.

Monday, March 07, 2005

And we got... Colors!

Just a minor update on things. I managed to get hold of a GeForce FX 5200. It's slow, but it does the job. I managed to upload the data as three 16bit Luminace planes, and use a pixel shader to combine the three images. Here is the result:





For some reason I've been imagining that Colors weren't recorded as RGB on my camera, but that makes the task a bit simpler. My next plan is implementing rudimentary color correction routines and some more GUI for them.

As the Bayer pattern interpolation really IS a comlicated thing on 3D hardware, I'm leaving it for a while and using the fast interpolation of dcraw.

Sunday, March 06, 2005

Camera RAW Experiments

Even though the tests I did when trying to utilize 3D hardware for video processing were pretty promising, I got an idea for a new and interesting way of using it. For processing RAW footage fra digital cameras. This is a far more obvious usage of modern 3D hardware, and it seems to be a lot better than current software implementations.

So I used the last weekend to throw together something that would enable me to try out some stuff and compare software processing to hardware processing. I haven't gotten too far yet, but I managed to get a test version running, using a hacked up version of dcraw and ufraw to read and decode the binary streams.

So basicly what I have now is the unfiltered and unconverted camera data which I plan to throw at my 3D hardware to see if it will be able to perform better than current software. What you see below is a pretty crude implementation, where I only read one color channel and maps it to luma on a texture.

Though I wont get too much into things that might not happend, I think 3D-accelleration is big win, and I get great performance so far, though no actual filtering is done yet. I need to get a DirectX 9.0c capable card again, so I can begin the real experiments, but the worst part seems to be done by now.

So far the Bayer pattern removal seems to be the biggest challenge, as dcraw uses a very sophisticated algorithm to remove Bayer patterns, that will probably be hard to do as is in hardware. But I hope to come up with something with the same quality. It is also quite a mystery to me how dcraw stores the Bayer pattern for each camera - dcraw might be small and very good at its task - but readable to humans is not one of its qualities. ;)

Anyway - gotta get some sleep. Here is a screenshot for the records:


Screenshot from the test application. The image is a RAW file imported from my Canon EOS 20D. It's not my happy face, though! ;)