c++ - Can I change a mat interpretation without changing the data? (Say mirror it) -


i have mat forms n x n matrix on need perform 1 algorithm several directions.

say want loop mat classically y = [0..n] , x = [0..n] , apply function on it.

then need loop mat y = [n..0] , x = [n..0] "other way" round. need approach mat 4 directions, (eg last 1 y = [0..n]/x = [n..0] , y = [n..0]/x = [0..n])

now don't want replicate code 4 times operation need apply more complex passing min, max , direction values 1 function like

void apply(cv::mat & mat, uint xstart, uint xend, uint xdirection, uint ystart, uint yend, uint ydirection); 

because algorithm ahead, etc.

now thinking if possible transform given matrix without changing it's data changing header interpretation of data. able call apply same parameters.

there operations cv::transform, cv::transpose etc create copy of data too, don't want.

no, cannot. quite simple if think memory storage. memory storage linear (row-wise) , without changing data can change step moving along linear memory. means can reshape , change type only.

transpose , reflection operations change data. still can cleaner , faster writing , running separate algorithms 4 search directions. of course, storing results of search can hassle since interpretations depend on mat configuration. so, avoid further complications, advice write 4 separate algorithms.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -