1 | initial version |
It is slower because it had to do more work. Not just increment the value of INT. First it to need to use row and col to calculate place in memory that should be incremented. It also need to access value in array. Random access to values in arrays is time consuming task. Read this tutorial for short review of how pixels of Mat should be accessed.