summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/disparity/src/c/padarray2.c
blob: 49f19384a18d49981c607592989e9d2b59a387b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/********************************
Author: Sravanthi Kota Venkata
********************************/

#include <stdio.h>
#include <stdlib.h>
#include "disparity.h"

I2D* padarray2(I2D* inMat, I2D* borderMat)
{
    int rows, cols, bRows, bCols, newRows, newCols;
    I2D *paddedArray;
    int i, j;

    rows = inMat->height;
    cols = inMat->width;
    
    bRows = borderMat->data[0];
    bCols = borderMat->data[1];
    
    newRows = rows + bRows*2;
    newCols = cols + bCols*2;
    
    paddedArray = iSetArray(newRows, newCols, 0);
    
    for(i=0; i<rows; i++)
        for(j=0; j<cols; j++)
            subsref(paddedArray, (bRows+i), (bCols+j)) = subsref(inMat, i, j);
    
    return paddedArray;
    
}