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: detect_blob_demo.m
    path of file: ./repos/mexopencv/samples
    
    the code of the file until where you have to start completion: %% Blob Detection
% This program demonstrates how to use BLOB to detect and filter region.
%
% Sources:
%
% * <https://github.com/o
    
function to convert params struct to pairs of name/value options
getopts = @(s) reshape([fieldnames(s), struct2cell(s)]', 1, []);

%% Detect
% blob detectors loop
for i=1:numel(p)
    % create detector using specified options
    opts = getopts(p(i));
    sbd = cv.SimpleBlobDetector(opts{:});

    % detect keypoint
    kpts = sbd.detect(img);

    % draw results
    out = cv.drawKeypoints(img, kpts);
    for k=1:numel(kpts)
        out = cv.circle(out, kpts(k).pt, round(kpts(k).size), ...
            'Color',randi([0 255],[1 3]));
    end