WDVM-TV does its community duty honorably tonight with a documentary on a de rigueur subject for major-market television stations, the plight of the homeless mentally ill. Released by the hundreds from U.S. mental institutions as part of a social reform gone wrong, many now live trapped in an urban purgatory, ignored and discarded.

In "Out of Sight, Out of Mind," at 8 on Channel 9, reporter Bruce Johnson calls deinstitutionalization of mental patients, from facilities like St. Elizabeths hospital here, "a good idea that was poorly implemented." The idea, when President Kennedy signed it into law in 1963, was to remove as many functioning mental patients as possible from cold-walled institutions and phase them back into society through "therapeutic centers."

But few such centers exist and many of the mentally ill aimlessly wander the streets. "We set many of these people free only to abandon them," Johnson says.

He interviews some of those with no place to go. One man, giving the appearance of being a merry street drunk, sings "Casper, the Friendly Ghost" and "My Guy." He does not appear unhappy with his plight. Others look overcome by melancholy and disorientation. A man named Noble says his ambitions in life extend no further than having "my own room, my own refrigerator, my own stove," yet there seems little chance of his achieving even that minimal level of contentment.

Johnson visits a privately run home for the mentally ill where conditions were scandalously squalid, but reports it has been taken over by more humane-minded operators and is being repaired. Seemingly model projects like the Green Door, which help patients readjust to the forbidding Outside World, offer hope.

Johnson notes that in the '50s and '60s, 8,000 mental patients were housed at St. Elizabeths, but only 1,500 are there now (one of them John Hinckley, not mentioned). One social ill, the overcrowded and understaffed mental institution, has been exchanged for another, streets and alleys filled with truly lost souls.

No attention is paid to the work done by Mitch Snyder locally in coming to the aid of the homeless, which seems strange, and the program makes awkward use of such production devices as color manipulation, freeze frames and music from the movie "American Gigolo." Produced by Jeane Bowers, "Out of Sight" is conscientious, but not up to what should be the standards of the best broadcast news operation in the city. Yet it is worthwhile and welcome just the same. % 'Behind the Screen'

WDCA-TV had virtue thrust upon it. The station has been responding in recent years to the demands of WATCH, a local citizens' group concerned about the mindless cartoon programs and aggressive commercials that bombard children who watch kiddy television. A project called Critical Television Viewing grew out of this campaign, and on Sunday, its maiden programming effort, "TV Behind the Screen," airs at 7 p.m. on Channel 20.

Dick Dyszel, the station's one-man cast of thousands, or at least several (including kiddie show host Captain 20 and horror movie host Count Gore DeVol), produced and hosts the program, whose purpose is to explain to children how TV stations and TV technology work. Young viewers are told how cameras operate, how some special effects are performed and, via a rather awkward demonstration involving pizza pies, why some shows go off the air while others stay on.

Unfortunately, much of this has the tone of mere station promotion (the promotion department, the busiest at many TV stations, is avoided during a station tour). Commercials are euphemistically referred to as "very important messages" from sponsors, for instance. Additionally, it may be trivial education to inform children what a PSA (public service announcement) is and how to read a rating book.

In explaining the ratings, Dyszel makes not even the meekest suggestion that some people criticize such a system of fallible audience measurement or the way it is allowed to dictate absolutely what choices will be available to the viewer. And if the goal is to be up front, perhaps Dyszel should have said something like, "Here at Channel 20, commercials are considered so very, very, very important that we'll just cut off the end of a movie and throw it away if we're running late and we haven't got all the ads in."

Ah, but we're being picky. WDCA does deserve credit for embarking on a project like this, even if the effort is on the minimal side. Minimal is better than nominal, after all, and nominal is better than nothing.