Intrinsic persistent homology via density-based metric learning