edit 2: I just ran across this page; Improvement of EPIC/DSCOVR Image Registration by Means of Automatic Coastline Detection and this paper Improvement of EPIC/DSCOVR Image Registration by Means of Automatic Coastline Detection. While it doesn't directly apply here, certainly automatic coastline detection or other surface feature detection could be useful if it can be put into a spacecraft.
edit 1: I believe the Mars 2020 Rover landing technique has been discussed in an answer or question here, but I can't find it right now. Here's a quick link, Spaceflight Insider.
A spacecraft in Earth orbit can indeed determine its own position relative to the Earth's center (to several kilometers, not "exactly") using terminator and star images, and a clock that measures elapsed time. I'll just answer the conceptual aspect of your question, assuming your spacecraft has modern electronics, imaging and computing (say a really nice, "price is no object" 3U cubesat) but you don't have a ground link to send location data to it from Earth, nor have GPS.
If you have several fixes spaced around the Earth's terminator, and knowledge of the shape of the Earth, you can indeed get the distance from the Earth and the direction of the Earth's center. Since the atmosphere has say 5 km of "noise" (clouds) it won't be perfect, but a given measurement should be reliable to about 1 part per thousand in distance.
Combine the vector (direction plus distance) towards the Earth's center with the spacecraft's attitude with respect to the stars using two star camera fixes (direction-only of course), and you can determine your 3D location in space with respect to the Earth's geometrical center to that 1 part per thousand; 7km in LEO or 40 km in GEO for example.
However keep making these measurements for a period of time of one orbit, and you have measured your distance much more precisely using a Keplerian (or better) model and the known mass of the Earth and tightened up the uncertainty substantially. (The more you sample the terminator, the more the clouds will tend to average out as well.) This just relies on your clock giving you elapsed time between measurements, not necessarily absolute time and date.
As soon as you are measuring for roughly the period of an orbit, you only need the direction to the center of the Earth, not the size. As the Earth's direction with respect to the stars is tracked and timestamped, you can fit it with a model for all of the orbital parameters, eccentricity, inclination, nodes, etc.
This all assumes you have well-calibrated cameras and the orientations of each camera's field of view with respect to all other cameras is known, or can be cross-calibrated in real time - depending how the spacecraft rotates and how dedicated vs flexible each camera is. It also assumes the cameras are built well to handle star or terminator imaging, don't get burned out by the Sun (star cameras often/usually have safety shutters), and you can manage your spacecraft's rotation (attitude) sufficiently to make sure the right cameras point at the right things.
Having fixes on the Sun and Moon will help you calculate the Earth's position relative position within the solar system barycenter if you need that. Of course if you have an ephemeris and your clock knows the actual time and date, you can have that already.