Add this to the onclick of each image listed in the popup. I assume a textarea in the main page called 'theImg' in a form called 'theForm'. Change as appropriate. If you want the text added instead of changed, make the assignment += instead of just =.
<img src='whatever.jpg' onClick='choose(this)'>
opener.document.forms['theForm'].elements['theImg'].value="<img src='"+img.src+"' />";