How to show Image FFT with origin as DC?
The quadrants of the FFT should be shifted Q1->Q3, Q2->Q4 ...
For a [RxC] matrix X this may be accomplished by shifting as:

tmpX = shift_row(    X, floor(R/2) )
Y    = shift_col( tmpX, floor(C/2) )


where shift_row and shift_col is your shift operator in each dimension and floor is the round towards zero operator.

For the inverse FFT shift you should shift in the same way but with a value -ceil(R/2) and -ceil(C/2), i.e rounded towards infinity