Does camera clarity vary with to the app? I own an old HTC Wildfire A333. I recently switched it back to the HTC Sense ROM and I saw that the quality of pictures taken with the default HTC camera app seem better. Not slightly. Quite a considerable amount actually. 

I know that picture clarity is related to the camera hardware. I switched back to CM9 again and when I turned the camera app on, I could see the clarity was bad (without taking pictures, just through the app interface. I did take pictures though and the quality was bad. The settings were all accounted for). 

Even when I used another camera app the quality was pretty bad. Sadly, I couldn't flash the HTC camera on the CM mod to see if that's what makes the difference. 

Does software affect the picture quality? If so, how?
Yes, software tweaks have a massive effect on image quality, and the htc sense version was optimised for you sensor, whereas the cm app wasn't, this is the difference between a well optimised app written to play to the strengths of a specific platform, and a general app written to give a moderately good experience on average. This same thing can be applied to cm more generally, with apps that use specific hardware (e.g. dialer) often having a worse experience compared to stock.