fixing the numbering of imagemat