You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: hi_res_browse_demo.m
    path of file: ./repos/mexopencv/samples
    
    the code of the file until where you have to start completion: %% Hi-Resolution Image Navigation
%
% Sample shows how to implement a simple hi-resolution image navigation.
% Similar to |imtool|.
%
%
    
function small = createThumbnail(img)
    %CREATETHUMBNAIL  Downsample image a few times to create a thumbnail image

    small = img;
    [h,w,~] = size(small);
    while max(h,w) > 512
        small = cv.pyrDown(small);
        [h,w,~] = size(small);
    end