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: hist_demo_gui.m
    path of file: ./repos/mexopencv/samples
    
    the code of the file until where you have to start completion: %% Intensity Image Histogram
% This program demonstrates the use of |cv.calcHist| for histogram creation.
%
% Sources:
%
% * <https://github.com/opencv/opencv/blob/3.1.0/samples/cpp/demhist.cpp>
%

function varargout = hist_demo_gui(im)
    % load source image
    if nargin < 1
        im = fullfile(mexopencv.root(),'test','img001.jpg');
        src = cv.imread(im, 'Grayscale',true);
    elseif ischar(
    
function onChange(~,~,h)
    %ONCHANGE  Event handler for UI controls

    % retrieve current values from UI controls
    histSize = 64;
    brightness = round(get(h.slid(1), 'Value'));
    contrast = round(get(h.slid(2), 'Value'));
    set(h.txt(1), 'String',sprintf('Brightness: %3d',brightness));
    set(h.txt(2), 'String',sprintf('Contrast: %3d',contrast));

    % brightness/contrast adjusted image
    % algorithm by Werner D. Streidt
    % <http://visca.com/ffactory/archives/5-99/msg00021.html>
    if contrast > 0
        delta = 127 * contrast/100;
        a = 255 / (255 - delta*2);
        b = a * (brightness - delta);
    else
        delta = -128 * contrast/100;
        a = (256 - delta*2) / 255;
        b = a * brightness + delta;
    end