function Io = imageNearest(Ii,dw,dh)
%%% function: image enlarge or zoom out with nearest interpolation
%%% Para: Ii - input gray image
%%% dw - scaling for width
%%% dh - scaling for height
[h, w] = size(Ii);
wo = w*dw;
ho = h*dh;
I_indexW = 1:wo;
I_indexW = I_indexW/dw;
I_indexW = floor(I_indexW+0.5);
I_indexH = 1:ho;
I_indexH = I_indexH';
I_indexH = I_indexH/dh;
I_indexH = floor(I_indexH+0.5);
Io = Ii(I_indexH,I_indexW);