This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
OpenCV types
David Miguel Lozano edited this page Oct 6, 2016
·
6 revisions
OpenCV's type convention is seen through the following expression:
CV_<bit_depth>{U|S|F}C(<number_of_channels>)
Here, U stands for unsigned, S for signed, and F stands for floating point.
Intensity ranges according to each bit depth and data type:
-
CV_8U
: These are the 8-bit unsigned integers that range from 0 to 255 -
CV_8S
: These are the 8-bit signed integers that range from -128 to 127 -
CV_16U
: These are the 16-bit unsigned integers that range from 0 to 65.535 -
CV_16S
: These are the 16-bit signed integers that range from -32.768 to 32.767 -
CV_32S
: These are the 32-bit signed integers that range from -2.147.483,648 to 2.147.483.647 -
CV_32F
: These are the 32-bit floating-point numbers that range fromFLT_MIN
to FLT_MAX and include INF and NAN values. -
CV_64F
: These are the 64-bit floating-point numbers that range fromDBL_MIN
toDBL_MAX
and include INF and NAN values.
If the number of channels is omitted, it evaluates to 1.
Java does not have any unsigned byte data type. The safe procedure is to cast it to an integer and use the And operator (&) with 0xff. Example: int unsignedValue = myUnsignedByte & 0xff;
. Now, unsignedValue
can be checked in the range of 0 to 255.
An 8-bit unsigned single-channel image:
Mat image1 = new Mat(480,640,CvType.CV_8U);
Mat image2 = new Mat(480,640,CvType.CV_8UC1);
A colored image represented by 32-bit floating point numbers:
Mat image3 = new Mat(480,640,CvType.CV_32FC3);