function [im] = im_corrdic(iminfo, showfig)


    method = 'dynamic_adjustment';

    imrgb = double(iminfo{1});
    im_name = iminfo{3};
    [m, n, r] = size(imrgb);
    
    im_r = im2col(imrgb(:,:,1),[1 1], 'distinct');
    im_b = im2col(imrgb(:,:,3),[1 1], 'distinct');
    
    switch method
        case 'static_threshold',
            dark_thresh = 128;
            im_b(im_b < dark_thresh) = im_b(find(im_b < dark_thresh)) + dark_thresh;
            
        case 'dynamic_adjustment',
            %dthresh = 0.009;
            dthresh = 0.005;
            
            x = repmat(0:255, [256 1]);
            y = x';
            z = (x .* 256) ./ (y + 1);
            zg = del2(z);
            zt = zg < dthresh;
            
            % Fixed 2009/10 to account for rare cases (virtually none in BDGP set) were im_r=0
            % Code used for TIs was: im_bmin = 255 - sum(zt(:,im_r));
            im_bmin = 255 - sum(zt(:,im_r+1));
            im_btadj = im_b - im_bmin;
            im_badj = im_btadj <= 0;
            im_b(im_badj) = im_bmin(im_badj);
    end

    im = (im_r .* 256) ./ (im_b + 1);

%     switch method
%         case 'dynamic_adjustment',
%             im(im_badj) = min(im);
%     end


    im = col2im(im, [1 1], [m n]);
    
    im = uint8(im);
    
    
    if showfig > 0,
        figure;
        title(im_name);
        subplot(1,2,1); imshow(uint8(imrgb));
        subplot(1,2,2); imshow(im);
    end
end
