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: imJointHistogram.m
    path of file: ./repos/matImage/matImage/imExplore
    
    the code of the file until where you have to start completion: function res = imJointHistogram(img1, img2, varargin)
% Joint histogram of two images.
%
%   HIST = imJointHistogram(IMG1, IMG2)
%   IMG1 and IMG2 are two images with the same size, HIST is a 256*256
%   array containing number of pixels for each combination of values.
%
%   HIST = imJointHistogram(IMG1, IMG2, NBINS)
%   Also specify the number of bins of the histogram. The result is a
%   square matrix with NBINS rows and NBINS columns. Default is 256.
%
%   HIST = imJointHistogram(IMG1, IMG2, NBINS1, NBINS2)
%   Specify different number of bins for each image.
%
%   HIST = imJointHistogram(IMG1, IMG2, BINS1, BINS2)
%   Directly specify the bins used for each image. The result is a matrix

    
function res = imJointHistogram(img1, img2, varargin)
% Joint histogram of two images.
%
%   HIST = imJointHistogram(IMG1, IMG2)
%   IMG1 and IMG2 are two images with the same size, HIST is a 256*256
%   array containing number of pixels for each combination of values.
%
%   HIST = imJointHistogram(IMG1, IMG2, NBINS)
%   Also specify the number of bins of the histogram. The result is a
%   square matrix with NBINS rows and NBINS columns. Default is 256.
%
%   HIST = imJointHistogram(IMG1, IMG2, NBINS1, NBINS2)
%   Specify different number of bins for each image.
%
%   HIST = imJointHistogram(IMG1, IMG2, BINS1, BINS2)
%   Directly specify the bins used for each image. The result is a matrix
%   with length(BINS1) rows and length(BINS2) columns. Default bins are
%   computed from 0 to maximal values (either maximal integer value for
%   integer images, or maximal image value for floating point images).
%   Image values that are below the first element of the corresponding bin
%   are dropped during the computation.
%
%   Works for 2D and 3D images, for grayscales (integer) and for intensity
%   (float) images.
%
%   Example
%     % Joint histogram of a grayscale image with a translated version of
%     % itself 
%     img = imread('cameraman.tif');
%     img2 = img(2:end