In Hebrew, the word 'imag-ination' has to do with the creating of an idol.
In the context of the Ten Commandments, it is an alternative object of worship, to God our Father, which Jesus brings into context in John 4:23.
That verse is given much greater context by John 4:22 - ye worship ye know not what. This alone, is a great sentence to wrestle with.
So, you will find many times 'imagination' is mentioned in the Old Testament, the most immediate translation is 'stubbornness'. Which, we would understand, more as a [u]refusal[/u] to give God His rightful place in their minds and hearts.
There is, however, one very interesting verse in the OT which stands out from the rest of those containing the word 'imagination'. It is: 1 Chr 29:18
O LORD God of Abraham, Isaac, and of Israel, our fathers, keep this for ever in the imagination of the thoughts of the heart of thy people, and prepare their heart unto thee:
(I'll leave you to check out the context, because it is very illuminating. David really understood God on this. David never once sacrificed to an idol, all the days of his life.) Paul brings David's thought/prayer into the context of the New Covenant - 1 Cor 6:19.
In general, I believe by 'vanity' or 'vain'ness, scripture means 'emptiness'. Psalm 115:4 Their idols [are] silver and gold, the work of men's hands. 5 They have mouths, but they speak not: eyes have they, but they see not: 6 They have ears, but they hear not: noses have they, but they smell not: 7 They have hands, but they handle not: feet have they, but they walk not: neither speak they through their throat. 8 They that make them are like unto them; [so is] every one that trusteth in them.
John Bunyan captures the constant pull of empty pursuits in his description of Vanity Fair; also, many very real mental challenges, in his Pilgrim's Progress.