This is a guess, since the question isn't really clear at all.
Type some text over the image. And do Edit > Copy. This will copy the text to the clipboard for use later.
Select both the image and the text. Open the Appearance panel, and click Opacity, then Make Mask, then select the Invert Mask option.
- Do Edit > Paste in Back. You won't see anything obviously change at this point. But there is now a copy of the text placed behind the masked object. Set a stroke, and increase the width until it has the desired thickness.