Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to rescale a depth map based on the requirement from Middlebury before submission

Status
Not open for further replies.

Nic Teo

Newbie level 2
Joined
Apr 17, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
12
Hi,

I would like to submit some of the results i have obtained from a stereo matching algorithms to Middlebury website https://vision.middlebury.edu/stereo/submit/

It stated there need to rescale the results from 4 to 16, below is the coding of mine

Code:
a = vision.ImageDataTypeConverter; %creates the object converts the input image to a single precision data type.
b = vision.ColorSpaceConverter('Conversion','RGB to intensity');
leftI3 = step(a,imread('teddyL.png')); % LEFT IMAGE step = step response of dynamic system
leftI = step(b,leftI3);
rightI3 = step(a,imread('teddyR.png'));% RIGHT IMAGE
rightI = step(b,rightI3);

%*******************************************************************Basic_Block_Matching******************************************************************************************************
Dbasic = zeros(size(leftI), 'single');
disparityRange = 45;
% Selects (2*halfBlockSize+1)-by-(2*halfBlockSize+1) block
halfBlockSize = 3;
blockSize = 2*halfBlockSize+1; %7X7 block
% Allocate space for all template matcher System objects.
tmats = cell(blockSize);

% Initialize progress bar
hWaitBar = waitbar(0, 'Performing basic block matching...');
nRowsLeft = size(leftI, 1); 

% Scan over all rows.
for m=1:nRowsLeft
    % Set min/max row bounds for image block.
    minr = max(1,m-halfBlockSize);
    maxr = min(nRowsLeft,m+halfBlockSize);
    % Scan over all columns.
    for n=1:size(leftI,2)
        minc = max(1,n-halfBlockSize);
        maxc = min(size(leftI,2),n+halfBlockSize);
        % Compute disparity bounds.
        mind = max( -disparityRange, 1-minc );
        maxd = min( disparityRange, size(leftI,2)-maxc );

        % Construct template and region of interest.
        template = rightI(minr:maxr,minc:maxc);
        templateCenter = floor((size(template)+1)/2);
        roi = [minc+templateCenter(2)+mind-1 ...
               minr+templateCenter(1)-1 ...
               maxd-mind+1 1];
        % Lookup proper TemplateMatcher object; create if empty.
        if isempty(tmats{size(template,1),size(template,2)})
            tmats{size(template,1),size(template,2)} = ...
                vision.TemplateMatcher('ROIInputPort',true);
        end
        thisTemplateMatcher = tmats{size(template,1),size(template,2)};

        % Run TemplateMatcher object.
        loc = step(thisTemplateMatcher, leftI, template, roi);
        Dbasic(m,n) = loc(1) - roi(1) + mind;
    end
    waitbar(m/nRowsLeft,hWaitBar);
end

close(hWaitBar);

figure(1), clf;
imshow(Dbasic,[]), axis image, colormap('jet'), colorbar;
caxis([0 disparityRange]);
title('Depth map from basic block matching');


What should i add inside the coding to rescale based on the scale of 4 and save it as a file?

Please help, thanks a lot!!
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top