Silhouette outline only shader?

After much googling it seems the most popular ways of getting an outline on any object is either the inverse hull method, or freestyle. The issue that I have with inverse hull is that it results in outlines “inside” the rendered object’s region


I’m looking for a real-time solution using shaders for getting results similar to what you get with free style contour, or how your objects is outlined when you select them

How should I approach this? I understand that it’s a bit redundant since free style exists, but I’m just really curious about a real time solution. Thanks.

Idea: IDK shader languages too much, but if the mask of the object (object white, background black) is used to find the black pixels neighbouring white ones and set to black in the final image ?