col2im.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <math.h>
00003 void col2im_add_pixel(float *im, int height, int width, int channels,
00004                         int row, int col, int channel, int pad, float val)
00005 {
00006     row -= pad;
00007     col -= pad;
00008 
00009     if (row < 0 || col < 0 ||
00010         row >= height || col >= width) return;
00011     im[col + width*(row + height*channel)] += val;
00012 }
00013 //This one might be too, can't remember.
00014 void col2im_cpu(float* data_col,
00015          int channels,  int height,  int width,
00016          int ksize,  int stride, int pad, float* data_im) 
00017 {
00018     int c,h,w;
00019     int height_col = (height + 2*pad - ksize) / stride + 1;
00020     int width_col = (width + 2*pad - ksize) / stride + 1;
00021 
00022     int channels_col = channels * ksize * ksize;
00023     for (c = 0; c < channels_col; ++c) {
00024         int w_offset = c % ksize;
00025         int h_offset = (c / ksize) % ksize;
00026         int c_im = c / ksize / ksize;
00027         for (h = 0; h < height_col; ++h) {
00028             for (w = 0; w < width_col; ++w) {
00029                 int im_row = h_offset + h * stride;
00030                 int im_col = w_offset + w * stride;
00031                 int col_index = (c * height_col + h) * width_col + w;
00032                 double val = data_col[col_index];
00033                 col2im_add_pixel(data_im, height, width, channels,
00034                         im_row, im_col, c_im, pad, val);
00035             }
00036         }
00037     }
00038 }
00039 


rail_object_detector
Author(s):
autogenerated on Sat Jun 8 2019 20:26:29