The words of Jesus are clear on one hand: it is wrong of course to judge according to appearance, to visibility, to outward behaviors. Judgment must be fair, considering also internal invisible factors: intentions, prehistory, possible long-term consequences... Problem appears when we remember that the same Jesus commands not to judge in general (Mt 7:1). Obvious contradiction, but God cannot indeed contradict Himself!
Actually, there is no contradiction. Christ calls not for a fair judgment from our point of view, but rather for a righteous judgment. But only a righteous man is capable of making a righteous judgment. Righteousness - is what belongs only to God. That is why Jesus does not approve de facto in these words human judgment, and instead rejects it: only God's judgment can be righteous.