Writing definitely changes one's perspective and helps in developing it - you begin to see things, people's lives...our life differently. I don't know about getting out of depression but writing certainly can be a portal to extreme escapism.
For me - Writing my characters and their stories make me happy - changes my mood and so on. I've learnt a lot about myself along the way and sometimes, re-reading a written record of your realizations and observations can help provide answers or confidence.
Whether you write only for yourself or to share with people, writing does affect perception but in a good way.