There is absolutely nothing wrong with seeing how someone dresses/acts and assuming that they like a style of music. Our fashion is heavily dictated by pop culture and so its usually a fairly accurate generalisation. However its one thing to assume someone listens to a certain genre of music, but its another entirely to judge someone based on their musical tastes.
For example, take the pic of Ice Cube in the OP.
Now he is a rapper, but even if you didn't know that by the way he dresses you would assume he is into hip hop, r&b etc. Now say you find out he's listening to Katy Perry, Taylor Swift etc. It goes against your assumption so you might say something like "i didn't know you listened to Katy Perry" which is fine. However if you said something like "you're listening to katy perry? you fag" then thats stupid.