Cobie Smulders says posing topless on the cover of a magazine was critical in helping her understand her body again after battling cancer.

"It was a very strange day," Smulders wrote in an essay for Lenny about her 2015 Women's Health photo shoot. "I was standing in front of a camera lens in my underwear and holding my breasts, all while trying to appear not sexy but confident."

The "How I Met Your Mother" star, now 34, was diagnosed with ovarian cancer in 2008.

Joanna Krupa shows off figure with topless selfie

"Just when your ovaries should be brimming with youthful follicles, cancerous cells overtook mine, threatening to end my fertility and potentially my life," the actress wrote of her diagnosis.

Several surgeries and two years later, Smulders was cancer free. She decided it was time to share her battle last year to Women's Health.

"So now that I’m on the other side of this, I feel like it is my duty, even if it means posing topless, to spread awareness,” she said. "Since my article in Women’s Health came out, I have had so many conversations with women about their own battles with cancer, and it feels so empowering to open up this dialogue and learn from each other."

Pics: Celebrity hand bra heroes

Smulders married former "Saturday Night Live" star Taran Killam in 2012. Together they have two daughters.