assert(rows <= MAX_HEIGHT);
assert(cols <= MAX_WIDTH);
for(int row = 0; row < rows; row++) {
#pragma HLS loop_flatten off
for(int col = 0; col < cols; col++) {
#pragma HLS pipeline II=1
RGB_PIXEL p;
img_0 >> p;
buffer[2] = buffer[1];
buffer[1] = buffer[0];
buffer[0] = p;
// Because we have a buffer above, the start of one line
// will be processed with data from the previous line.
// The check below is a simple, relatively unsophisticated
// way to handle the edge condition. It does result in
// introducing a spatial shift in the image because the
// filter is non-causal.
if(col > 1) {
for(int i = 0; i < 3; i++) {
bool a = buffer[2].val[i] > buffer[1].val[i];
bool b = buffer[2].val[i] > buffer[0].val[i];
bool c = buffer[1].val[i] > buffer[0].val[i];