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: detGM.m
    path of file: ./repos/Image-Harmonization-Dataset-iHarmony4/Lalonde and Efros/colorStatistics/3rd_party/segmentationBerkeley/Detectors
    
    the code of the file until where you have to start completion: function [m,theta] = detGM(im,sigma)
% function [m,theta] = detGM(im,sigma)
%
% Compute image gradient magnitude.
%
% INPUT

    
function [m,theta] = detGM(im,sigma)
% function [m,theta] = detGM(im,sigma)
%
% Compute image gradient magnitude.
%
% INPUT
%	im	Image.
%	sigma	Scale at which to compute image derivatives.
%
% OUTPUT
%	m	Gradient magnitude.
%	theta	Orientation of gradient + pi/2 
%		(i.e. edge orientation).
%
% David R. Martin <dmartin@eecs.berkeley.edu>
% March 2003

if isrgb(im), im=rgb2gray(im); end