Ask Your Question
0

Is it Possible to Create a Continuous Image?

asked 2014-09-02 03:17:10 -0500

Adi gravatar image

updated 2014-09-02 03:18:01 -0500

Is it possible to create a cv::Mat of arbitrary size for which isContinuous() will return true, i.e. no row padding, without using externally allocated data?

It seems that only the constructor for using externally allocated data supports setting the step/stride variable.

edit retag flag offensive close merge delete

Comments

any Mat created (without an external data pointer) will be continuous

berak gravatar imageberak ( 2014-09-02 03:52:57 -0500 )edit

Are you sure about this? Where is this written? Most MMX/SSE operations work much faster on aligned and padded data (rows). I had assumed OpenCV automatically adds padding for 4 or 8 byte multiples (as e.g. IPL and IPP did/does).

Adi gravatar imageAdi ( 2014-09-02 05:16:21 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-09-02 05:58:17 -0500

Daniil Osokin gravatar image

updated 2014-09-02 07:12:15 -0500

Hi Adi,

Allocation is done in Mat::create function, it's aligned, but continuous memory strip.

edit flag offensive delete link more

Comments

OK, so it is, indeed, as @berak said. In that case, it is the exact opposite of my question. cv::Mat is always created continuous unless it was constructed with padded data (or via ROI related operations).
The line you point to allocates by stride, so step.p[0] can still contain padding, but it seems that setSize() above it set it to the default continuous data.

Adi gravatar imageAdi ( 2014-09-02 07:30:24 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-09-02 03:17:10 -0500

Seen: 506 times

Last updated: Sep 02 '14