You can pass a reference to the image as a parameter.
function changeImage(x){
document.getElementById('image').src = x.src;
}
You can continue to call the function using your first way:
<img src="<?php echo $image['thumb']; ?>" onclick="changeImage(this)" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" />