This image is NGC 6543 known as the Cat's Eye Nebula as it appears to the Chandra X-Ray Observatory and Hubble Telescope. A planetary nebula is a phase of stellar evolution that the sun should experience several billion years from now, when it expands to become a red giant and then sheds most of its outer layers, leaving behind a hot core that contracts to form a dense white dwarf star. This image was released Oct. 10, 2012.

Amazing glowing nebulas resembling cosmic candy take center stage in a group of new photos unveiled today (Oct 10) by the science team behind NASA's Chandra X-ray Observatory.

The pictures are part of a survey the Chandra space telescope is making of nearby planetary nebulas, which are formed when dying stars push off their outer gaseous layers. The first stage of this survey, which includes Chandra observations of 21 of these nebulas, has now been released. Chandra also released a video of the surveyed nebulas.

Chandra observes the universe in short-wavelength X-ray light. This data, shown in pink, was combined with optical imagery from the Hubble Space Telescope, shown in red, green and blue. The four nebulas pictured above are the Cat's Eye nebula (NGC 6543), as well as NGC 7662, NGC 7009 and NGC 6826.

"Planetary nebulae have provided astrophysicists with dying star 'laboratories' for more than a century," Rochester Institute of Technology astronomer Joel Kastner, who led the study, said in a statement. "They provide test beds for theories of stellar evolution and give us insight into the origin of heavy elements in the universe and on Earth. Yet we still don’t fully understand why they take on such a dazzling variety of shapes."

All the nebulas being studied in the survey lie relatively close, astronomically speaking, within 5,000 light-years of Earth. [Gallery: Amazing Chandra Nebula Photos]

"Because they all just happen to lie relatively nearby, we think this group of objects is fairly representative of planetary nebulae in general," Kastner said.

The sun itself is expected to produce a planetary nebula in several billion years. This will happen when the sun runs out of hydrogen to burn up in its core, and expands into a red giant star, engulfing the Earth and inner planets of the solar system in its new radius that will be tens to hundreds of times wider.

Then the sun, like all stars at this stage, will puff out its external layers while its hot core collapses down into a dense white dwarf star. This hot core will emit a fast wind that speeds outward, pushing out the ejected gas layers to create the glowing shells typical of planetary nebulas.

The diffuse X-ray light observed by Chandra in the four nebulas above is thought to be caused by shock waves created when the stellar wind hits the gaseous layers.

About half of the new Chandra photos also reveal bright points of X-ray light in the centers of the nebulas that could indicate the presence of a companion star in addition to the white dwarfs there. This suggests that stars with planetary nebulas have a high likelihood of being part of binary star systems.

"Future studies should help clarify the role of double stars in determining the structure and evolution of planetary nebulas," Chandra scientists wrote in a statement. For instance, companion stars may help explain why many planetary nebulas aren't spherical.

The $1.65 billion Chandra observatory was launched on space shuttle Columbia in July 1999.

The new Chandra findings were reported in a study published in the August 2012 issue of The Astronomical Journal.

Follow SPACE.com on Twitter @Spacedotcom. We're also on Facebook & Google+.