Ask Your Question
0

Is there a way to use decimation in OpenCV algorithms?

asked 2018-12-26 01:53:22 -0500

egorii gravatar image

For example, we have a function such as addWeighted. So, is there simple way to say that function: "I want use only every 2nd column of image data."? If such method doesn't exist, maybe I can improve some places in OpenCV code with few strings? Finally, if I change for example value of Mat::step, it may get similar effect?

edit retag flag offensive close merge delete

Comments

what is your "use-case" for this ?

berak gravatar imageberak ( 2018-12-26 01:59:23 -0500 )edit

if I change for example value of Mat::step

oh, noes, please don't mess with the Mat's internal data, you'll only ** up

berak gravatar imageberak ( 2018-12-26 02:09:53 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-12-26 02:08:08 -0500

berak gravatar image

you can resize() your Mat, using the INTER_NEAREST flag:

Mat_<uchar> m(1,10);
m << 0,1,2,3,4,5,6,7,8,9;

resize(m,m,Size(m.cols/2, m.rows), 0, 0, INTER_NEAREST);

cout << m;

[  0,   2,   4,   6,   8]
edit flag offensive delete link more

Comments

so, I will try, thanks

egorii gravatar imageegorii ( 2018-12-26 02:13:32 -0500 )edit

It's effective only if you using one conversion (resizing) with many many operations with the same Mat after.

egorii gravatar imageegorii ( 2018-12-26 22:00:08 -0500 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2018-12-26 01:53:22 -0500

Seen: 41 times

Last updated: Dec 26 '18