All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Thinking about a specific naked woman is forbidden, but if the thought is about an unspecific woman, then this is not forbidden but it is better to avoid it.
Shaykh ibn ‘Uthaymeen said:
“If one thinks [of a naked woman] and then ejaculates, then he is not sinful, but he must not think about a specific woman because thinking about a specific woman is a cause of temptation. This is because when he thinks about her, the devil may incite him to call her, or that he will be attached to her, but if he just thinks about this in general, like imagining that he has sexual intercourse with a woman, for example, and then he ejaculates, then there is nothing wrong. However, we advise to avoid it because what is not normal generally leads to harm more than to benefit.” [End of quote]
You should know that Allah –out of His Mercy for this nation –He has forgiven them about the thoughts that they have unless they speak about them or act according to them, as confirmed in an authentic Hadeeth of the Prophet .
Hence, there is no sin about mere thoughts. However, a wise person guards his thoughts and avoids thinking about what does not benefit him; rather, he should think about matters of benefit to him in his religion and his worldly matters. This is because false ideas may lead to false wills, whereby a person is held accountable for forbidden determinations. Thinking about what is forbidden when one reaches the stage of being firmly determined to do them is forbidden. But thinking about what is lawful is permissible and the person is not sinful for it.
However, as we have previously mentioned, he should only think about what benefits him in his religion and worldly life.
Ibn Al-Qayyim, may Allaah have mercy him, said:
“Thought are divided into four categories:
A- Thoughts by which a person gets his worldly and religious benefits.
B- Thoughts by which a person repels what harms him in his worldly life.
C- Thoughts by which a person gets the benefits of his Hereafter.
D- Thoughts by which a person repels what harms him in his Hereafter.
So a person should limit his thoughts, worries, and concerns to these four categories. [….]” [End of quote]
There is a continuation of this statement of Ibn Al-Qayyim, may Allah have mercy him, in his book ad-Daa’ wad-Dawaa’, if you wish to refer to it.
Allah knows best.