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: average_feature_region.m
    path of file: ./repos/ECO/feature_extraction
    
    the code of the file until where you have to start completion: function [ region_image ] = average_feature_region(im, region_size)
% compute cell wise averages, where a cell is a region_size*region_sized
% region in the image. Input can be uint8t, single or double matrices
% of arbitrary dimension

region_area = region_size.^2;


    
function [ region_image ] = average_feature_region(im, region_size)
% compute cell wise averages, where a cell is a region_size*region_sized
% region in the image. Input can be uint8t, single or double matrices
% of arbitrary dimension

region_area = region_size.^2;

if isa(im,'double') || isa(im,'single') || isa(im,'gpuArray')
    maxval = 1.0;
elseif isa(im,'unit8')
    maxval = 255;
end