Lagos is an African megacity humming with chaotic energy. Potholed roads and even the city’s superhighways are crowded with traffic, overloaded vendors, earsplitting noise, choking pollution, piercing colors and powerful smells. Extreme wealth is set against a backdrop of grinding poverty, hope battles despair, daily acts of kindness and generosity are offset by cruelty, greed and corruption, and creativity is inspired by necessity because of the city’s broken infrastructure and the looming threat of ruin. Between these extremes, and usually to the background drone of a generator, exist the rich and textured lives of some 20 million people.

Lagos is long overdue for a book that captures this kaleidoscope of random energy, disorder and color. “Africa Under the Prism,” just published by Hatje Cantz, gathers work shown during the first five years of LagosPhoto, an international arts festival begun in 2010 to reflect African perspectives and realities.

The festival’s aim is to challenge Afro-pessimism and the visual overrepresentation of Africa as a continent of the dying, desperate and helpless. It recently held its sixth edition, and much of the festival’s success rests on its ability to tap into the creative vibe of Africa’s most populous city. While “Africa Under the Prism” features works by Nigerian photographers shooting in Lagos, the book’s content spans the breadth of the continent.

“It is easy to expect the book to be representative of Lagos, but it’s really a chronological sequence of the work we have done with the festival over the years, and not a book about Lagos,” the festival founder and director Azu Nwagbogu said.

As such, it mirrors the evolution from the festival’s early days of African photographers telling African stories to more expansive conceptual work, and the inclusion of projects that were rarely seen in Africa, like the Dutch photographer Kadir van Lohuizen’s “Diamond Matters,” which charts the diamond trade from excavation in Africa to markets overseas.

Photo

The result is a record — at times uneven — of a particular period in African photography. Long gone is the homogeneous colonial gaze portraying the “civilizing” work of exploitative European empires, as is the image of the noble savage. Western media tropes are also challenged. With the spread of digital technology and the growth of Internet access on the continent, we now have insight into the complex inner lives of “subjects” once observed only from the outside. This self-expression broadens the filter through which we view a diverse continent.

Some of the book’s stronger work explores identity in projects such as the South African photographer Mary Sibande’s “Long Live the Dead Queen,” a series of self-portraits featuring her alter ego, a domestic worker, dressed in striking blue outfits against a stark white background, and the Nigerian photographer Jenevieve Aken’s “Masked Woman,” another self-portrait series revealing Ms. Aken, a former model, performing the role of a femme fatale in a black-and-white examination of women’s roles in Nigeria.

The Zimbabwean artist Kudzanai Chiurai’s “State of the Nation” features hyperstylized, ultrachromatic scenes probing how conflict can give birth to something else, even the possibility of a female head of state. “Flamboya,” by the Dutch artist Viviane Sassen, offers dreamy and seductive images that speak to the legacy of an imperialist aesthetic reimagined through a combination of documentary and staged photography that offers a fresh view of modern Africa.

Photo

The quality of these and other projects featured in the book highlights a weakness: With a few notable exceptions, the work from Lagos is the least accomplished, meaning the festival has yet to capture the frenetic energy of its host city. This is an honest representation of the festival’s output to date, Mr. Nwagbogu said, explaining that a main objective of the festival was to address this gap by helping African photographers to mature through collaboration with outside artists.

Such creative growth means that a book about Lagos is finally in the offing. Over the years, established photographers invited to the festival, including Stanley Greene of the United States, Robin Hammond of New Zealand and Mr. van Lohuizen, among many others, have worked with a handful of Nigerian photographers to document the city for a book of combined work titled “Lagos: Entropy Unchecked,” to be published in 2016. Until then, “Africa Under the Prism” offers a glimpse at LagosPhoto’s past, and potential.

Finbarr O’Reilly is a 2015 World Fellow at Yale, where he is working on a book, “Shooting Ghosts,” about the psychological costs of war, to be published in 2017 by the Viking imprint of Penguin/Random House. He was based in Africa as a Reuters reporter and photographer between 2001 and 2014 and was awarded the World Press Photo of the Year in 2006. Follow him on Twitter, Facebook and Instagram.

Follow @nytimesphoto on Twitter. You can also find us on Facebook and Instagram.