I've owned a couple of those; when I say "this space" I mean top-of-the-line smartphones with great cameras. Those Samsung & Sony phones fulfilled only one of those parameters.
I can't speak to the Sony phones, but for at least a couple of generations (Galaxy S6, S7, Note 5, Note 7, etc.), Samsung phones have been right there with the iPhone in terms of camera quality. The S6 beat the iPhone 6S+ by about the same DxOMark margin as the Pixel is beating the iPhone 7.
Looking at any sort of comparative review, you'll find that on some shots the Samsung produces better results; on others, an iPhone looks better. Each phone may perform a little differently in different situations -- low light, high contrast, whatever. But taken as a whole, at least some Android flagships' cameras have been as good as the iPhone's for a couple of years now.
Nexus phones have been noticeably worse, but they've also tended to cost 60% as much, so it's not exactly an easy comparison to make.
"Nonsense", to the other responses to your question, the 5X camera (along with the 6P) is outstanding! I consistently "out-shoot" friends with the iPhone in side by side photo situations. This usually involves low light so I can't speak to other scenarios. My 5x camera is one the reasons I love the phone, among quite a few others.
I own a 5x. The camera will be the primary reason I upgrade before I really need to. Its mostly decent but occasionally bad: Out of focus (or incorrect focal point), extremely poor in low light, occasionally crashes (not doing anything fancy here). I think the phone overall is good, and I can't imagine using non-vanilla android. But prior to the Pixel announcement (and after owning this and last gen's Nexus) I'd started considering giving the iPhone a try based solely on the camera.