c++ - How to vectorize loop operating on 3 channel OpenCV Mat? -
i'm trying improve performance in code operating on 3 channel opencv matrix. loop looks this:
unsigned char *input = (unsigned char*)(img_input.data); // 3 channel rgb unsigned char *output = (unsigned char*)(img_output.data); // 1 channel for(int j = 0;j < img_input.rows;j++){ for(int = 0;i < img_input.cols;i++){ unsigned char b = input[numcols * j + 3 * ] ; unsigned char g = input[numcols * j + 3 * + 1]; unsigned char r = input[numcols * j + 3 * + 2]; output[numcols * j + i] = // operations r g , b here } }
now gcc can't vectorise this
complicated access pattern
which isn't surprising. vectorises ok if have 2 channel, seems gcc looks multiples of 2 in loop index increment when vectorising.
question: there way vectorise loop isn't separating input matrix 3 separate matrices ?
thanks.
Comments
Post a Comment