BEIJING — When officials in an eastern Chinese city were told to root out “uncivilized behavior,” they were given a powerful tool to carry out their mission: facial recognition software.

Among their top targets? People wearing pajamas in public.

On Monday, the urban management department of Suzhou, a city of six million people in Anhui Province, sparked outrage online when it published surveillance photos taken by street cameras of seven residents wearing pajamas in public along with parts of their names, government identification numbers and the locations where their “uncivilized behavior” had taken place.

City officials quickly apologized, but not before stirring nationwide ire over the use of a state-of-the-art digital tool to stamp out a harmless and relatively common practice — an unusual note of resistance in a country where the instruments of digital totalitarianism have spread largely unchecked.

On social media, the Suzhou department publicly called out, among others, a Ms. Dong, a young woman in a plush pink robe, matching pants and orange pointy flats, walking on a street, and a Mr. Niu, who was singled out for donning a black-and-white-checkered full pajama suit in a mall.