The state's highest criminal court on Wednesday tossed out part of a Texas law banning "improper photography or visual recording" - surreptitious images acquired in public for sexual gratification, often called "upskirting" or "downblousing" - as a violation of federal free-speech rights and an improper restriction on a person's right to individual thoughts.

In an 8-1 ruling, the Texas Court of Criminal Appeals said photos, like paintings, films and books, are "inherently expressive" and, therefore, are protected by the First Amendment. The opinion supported a previous decision by the San Antonio-based 4th Court of Appeals.

"The camera is essentially the photographer's pen and paintbrush," the opinion written by Presiding Judge Sharon Keller said. "A person's purposeful creation of photographs and visual recordings is entitled to the same First Amendment protection as the photographs and visual recordings themselves."

The appeal questioned why some free speech can be treated as unlawful behavior in Texas. Peter Linzer, who teaches constitutional and First Amendment law at the University of Houston Law Center, said: "It's hard to see how you could make taking a picture a crime."

The case involved Ronald Thompson, who was charged in 2011 with 26 counts of improper photography after taking underwater pictures of clothed children - most wearing swimsuits - at a San Antonio water park. He appealed the law's constitutionality before his trial. He contended that a plain reading of the law would place street photographers, entertainment journalists, arts patrons, pep rally attendees and "even the harmless eccentric" at risk of incarceration.

In its arguments, the Bexar County District Attorney's Office asserted that the law's intent element - such as trying to do something unlawful - places otherwise expressive activity beyond First Amendment protection.

The court disagreed.

"Protecting someone who appears in public from being the object of sexual thoughts seems to be the sort of 'paternalistic interest in regulating the defendant's mind' that the First Amendment was designed to guard against," Keller wrote. "We also keep in mind the Supreme Court's admonition that the forms of speech that are exempt from First Amendment protection are limited, and we should not be quick to recognize new categories of unprotected expression."

Linzer said the court rendered a sound decision.

"To think that it's unlawful to look at a little girl in a swimsuit, when you have lascivious thoughts, in public? And you did not do anything to that child? That cannot be made a crime in the United States," he said. "The fact that some people might find that very offensive doesn't change anything. ... You can't prevent someone in public from looking at you and having dark thoughts."

Linzer added that the opinion also exposes the statute as excessive. "It simply goes beyond things that can be done legally and constitutionally," he said.

An amicus brief supporting Thompson was filed by the Reporters Committee for Freedom of the Press, which argued that the state could revise the law to avoid First Amendment challenges by focusing on circumstances that are not in public.

Under the Texas Penal Code section on sexual offenses, it is a crime to electronically photograph or record a visual image of someone who is not in a bathroom or private dressing room without the other person's consent and "with intent to arouse or gratify the sexual desire of any person." The ruling does not address the constitutionality of the statute's latter part that involves the broadcast or transmission of images.

At least 151 inappropriate photography cases have been filed in Harris County during the past 13 years. Roughly 15 of those are pending.

Current and resolved cases could be affected by the criminal appeals court's ruling, according to Harris County District Attorney's Office spokesman Jeff McShan.

There is one Harris County case on appeal involving a cellphone left in a Tomball department store dressing room in 2012 that captured clandestine footage of a girl's behind. Last year, a jury convicted Tomball resident Ronnie Royston, now 40, as the person who arranged the video and he was sentenced to four years of probation.

Other recent local prosecutions include a 12-year-old Channelview girl who photographed a classmate in a middle-school locker room in 2012. The image didn't show nudity, was never posted online and was deleted minutes later. A jury convicted the pre-teen of a felony in 2013. She was placed on probation for one year.