You could start a session on the page containing the <img> tag, use "images.php?id=filename" as the src attribute. Then images.php checks to see if the session has been started, and if it has, readfile()s the image (with the appropriate Content-Type: header). The image files themselves are stored in an inaccessible directory, so there is no URL that leads directly to them.
Then it would only be accessible by someone who actually requested it via the original page.
You may find other solutions if you try a search for "hotlinking", as the thing you're describing is called.