How does the Hubble keep everything in focus?

This is pretty much a basic photography question…

I love-love-love checking out the Astronomy pic o’ the day every morning. Today’s made me think of something: the nebula is in fantastic focus, but so are the galaxies millions of light years further away. How does the Hubble’s camera keep everything sharp? Did they composite a sharp-galaxy-blurry-nebula pic with a blurry-galaxy-sharp-nebula pic?

When the closest object in a photo is billions of miles away, no significant depth of field is required for everything to be in focus. IOW, for the purpose of photography, everything in the heavens (or at least everything outside our solar system) is at infinity.

Ditto Xema. A better way to think of depth of field is how different the direction to the subject is, as viewed from opposite edges of the lens or mirror. So, if one person is ten feet behind another, and you stand a few inches in front of the closer person, the focus is very different for them - but if you are a thousand feet away, the focus is practically indistinguishable.

That’s why the numbers on the focus ring of the lens are so nonuniformly spaced.

Another way of looking at it: “Infinity” in optics just means “much much further than the focal length”. The Hubble has a focal length of a few meters, and the closest object it’s ever looked at is nearly 400 million meters away, or hundreds of millions of times the focal length. Which is good enough to be called “infinity”.

Long time lurker, first time poster.

I was one of the earliest employees at what was then known as “Space Telescope Science Institute” - the “Hubble” part came much later.

The images themselves go through an enormous amount of pre-processing from the raw data, even after the telemetry data is stripped out. They don’t just come off the camera preformed in a jpg image or anything like that.

I worked on designing and implementing the earliest processing software used by astronomers to process the data. In modern terms, it was comparable to such common software today as Photoshop, GIMP, and statistical scripting languages such as R.

What you can get today for free, and can spend less then 500 dollars to have sufficient hardware to run it, cost quite a bit more at the time. I remember what I believe to be one of the first DEC VAX 8600 clusters supporting the development work. That filled a pretty large room. Your PC today provides much more horsepower thanks to Moore’s law.

On a related note, maybe someday I will explain not only how the pictures are in focus (focal length more or less, as noted - and a flawed mirror with corrections built into the software, don’t forget!), but also why there is no jitter - how does the satellite lock onto an image and keep the image from blurring?

I thought I saw some mention of a Hubble view of the Space Station or a Shuttle or something like that, which was at photographically practically infinite distance but still required an oh-so-slight focus shift to be optimally sharp. Maybe in Sky & Telescope? Anybody remember?

Hubble time is far too valuable to be wasted on something as frivolous as the Space Shuttle, and I’d be highly surprised if it even has an adjustable focus at all (if it can be adjusted, it can be misadjusted). So far as I know, the nearest object it’s ever looked at is the Moon.

It’s been a decade since I’ve worked with Hubble data… That would be IRAF, if I recall?

Sorry for the delay in responding… IIRC IRAF was a scripting language sort of, yes? What I worked on was the specific image processing algorithms that were called by the scripting language. I forget the internal acronyms at the moment, not sure if they were used by the wider community in practice or not as I was gone before launch.