Thanks Bart, I didn't know that. In any case, if I understand correctly, that method requires more than one image to work and cannot be applied to a single image.
That's correct, two overlapping images are required to achieve that.
Imagine two images with barrel distortion, ideally overlapping the same scene fragment by 50% for the best result (and rotated through the entrance pupil to avoid parallax). The left side image will radially shift details to the right in the right half of the image. The same details in the right side image will shift radially to the left in the overlapping left half of the image. The image centers ar not distorted and they align.
Now the software adjusts the distortion parameter(s) for both images until they match between both images, just like the image centers did all the time for the undistorted optical center. That will unveil the distortion parameters with two images, even for more complex distortions, like combined pincushion and barrel distortion, e.g. moustache distortion.
There is a possibility to do this with one image, but then the subject matter must be a regular predictable straight lines grid, or a grid of dots, or modern architecture with many windows or balconies at regular straight line intervals. By instructing the Pano-software that straight lines must be rendered as straight lines, and setting multiple line segments, the software can calculate which distortion is required to really line up the line segments. Distortion is characterized and the parameters can be applied to other images which do not offer such features.
Part of this functionality is becoming available in LR/ACR as the so-called "Upright" functionality, which takes its clues from image features"and guesses what the geometry is supposed to be. This sometimes works to produce squared images. Distortion is more complex than simple tilt of the camera, and not all scene content offers enough clues to work on.