Scott Williams, neighbors said, makes everyone around him feel safer in the quiet cul-de-sac off a rural two-lane highway in Calvert County. The D.C. police officer always carries himself like a cop — confident, cautious and stern — and his house offers a sort of warning to would-be criminals with a sign on a large wooden fence in the yard.

“Caution,” it says. “Police K-9 on Premises.”

“Knowing that I’m here and he’s behind me and a cop, I feel safe. I really do,” said neighbor Patricia Nelson, 40. “He’s just a great person.”

Williams, a D.C. police canine officer with 23 years on the force, was shot in the legs Monday as he responded to the Navy Yard mass shooting, authorities said. Doctors initially feared that he wouldn’t be able to walk again, but his condition has steadily improved.

Charles Yarbaugh, a retired D.C. police officer and longtime friend, said that Williams told him in a brief phone conversation that he could leave the hospital as soon as Thursday night or Friday morning. James Thrift, a friend of Williams’s who owns a mixed-martial-arts academy where Williams trains, said Williams “tried to get out of bed to give me a hug” during a recent hospital visit.

“He told me he can’t wait to get back to training again,” Thrift said.

Family members of Williams declined to comment for this article. But friends and former colleagues described him as a dedicated and adept officer, and a loving dog handler known for his integrity and restraint. Police Chief Cathy L. Lanier said Williams, whom she has known for “many, many years,” is an officer with a “stellar record.”

Jim Ginger, a retired D.C. police canine sergeant who worked with Williams, said Williams trained at least two shepherd-type police dogs — Hulk and Apis — and was known among his colleagues as an avid hunter who played soccer and cared a lot about his physical fitness.

“Real calm, quiet,” said Ginger, who retired in 2011. “The whole time I knew him, I don’t think he ever got a use-of-force complaint.”

Added Thrift, who works in law enforcement, “He’s the type of cop that every other cop wants to be.”

What precisely happened to Williams in the confines of the Navy Yard, where a gunman killed 12 people, remains unclear. Yarbaugh said Williams told him only that he “got hit in the leg and he went down and lost sight of the guy in the building.”

What is more certain, though, is that Williams is the type of officer who would have been prepared to handle such an intense incident, friends said. Yarbaugh, who was a sergeant in the Special Operations Division and had trained other officers, said Williams was “one of the better students that I had in the active-shooter program.”

Thrift said he considers his friend a hero, saying, “He went in there without any thought to his own safety, just knowing he had to help other people.”

Mike DeBonis and Clarence Williams contributed to this report.