The ’image’ functionality in R is somehow counter-intuitive. Let us say, we want to visualise a matrix of values m. Applying image(m) will result in a plot corresponding to the transformation where the matrix is first transposed (rows become columns) and then the rows are flipped (first row becomes last, second becomes second to last and so on). To fix this behaviour and plot the given matrix as it is we need to apply the inverse transform, i.e. first reverse row numbers, then transpose the resulting matrix as shown below.