How do I differentiate between these images using opencv and PCA?

Ah, ok, I see.
I prefer to use PCA on the gradients to get the structure tensor, which is a more robust solution - I was thinking OP was trying to achieve this.