Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
7c226ed7
Commit
7c226ed7
authored
Sep 24, 2015
by
Suleyman TURKMEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding new flags to imread to load image reduced
parent
7d7f5c19
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
38 deletions
+25
-38
imgcodecs.hpp
modules/imgcodecs/include/opencv2/imgcodecs.hpp
+7
-9
loadsave.cpp
modules/imgcodecs/src/loadsave.cpp
+18
-29
No files found.
modules/imgcodecs/include/opencv2/imgcodecs.hpp
View file @
7c226ed7
...
...
@@ -67,7 +67,13 @@ enum ImreadModes {
IMREAD_COLOR
=
1
,
//!< If set, always convert image to the 3 channel BGR color image.
IMREAD_ANYDEPTH
=
2
,
//!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR
=
4
,
//!< If set, the image is read in any possible color format.
IMREAD_LOAD_GDAL
=
8
//!< If set, use the gdal driver for loading the image.
IMREAD_LOAD_GDAL
=
8
,
//!< If set, use the gdal driver for loading the image.
IMREAD_GRAYSCALE_REDUCED_2
=
16
,
//!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
IMREAD_COLOR_REDUCED_2
=
17
,
//!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
IMREAD_GRAYSCALE_REDUCED_4
=
32
,
//!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
IMREAD_COLOR_REDUCED_4
=
33
,
//!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
IMREAD_GRAYSCALE_REDUCED_8
=
64
,
//!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
IMREAD_COLOR_REDUCED_8
=
65
//!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
};
//! Imwrite flags
...
...
@@ -133,14 +139,6 @@ returns an empty matrix ( Mat::data==NULL ). Currently, the following file forma
*/
CV_EXPORTS_W
Mat
imread
(
const
String
&
filename
,
int
flags
=
IMREAD_COLOR
);
/** @brief Loads and resizes down an image from a file.
@anchor imread_reduced
@param filename Name of file to be loaded.
@param flags Flag that can take values of @ref cv::ImreadModes
@param scale_denom
*/
CV_EXPORTS_W
Mat
imread_reduced
(
const
String
&
filename
,
int
flags
=
IMREAD_COLOR
,
int
scale_denom
=
1
);
/** @brief Loads a multi-page image from a file. (see imread for details.)
@param filename Name of file to be loaded.
...
...
modules/imgcodecs/src/loadsave.cpp
View file @
7c226ed7
...
...
@@ -238,7 +238,7 @@ enum { LOAD_CVMAT=0, LOAD_IMAGE=1, LOAD_MAT=2 };
*
*/
static
void
*
imread_
(
const
String
&
filename
,
int
flags
,
int
hdrtype
,
Mat
*
mat
=
0
,
int
scale_denom
=
1
)
imread_
(
const
String
&
filename
,
int
flags
,
int
hdrtype
,
Mat
*
mat
=
0
)
{
IplImage
*
image
=
0
;
CvMat
*
matrix
=
0
;
...
...
@@ -252,7 +252,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
decoder
=
GdalDecoder
().
newDecoder
();
}
else
{
#endif
decoder
=
findDecoder
(
filename
);
decoder
=
findDecoder
(
filename
);
#ifdef HAVE_GDAL
}
#endif
...
...
@@ -262,11 +262,22 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
return
0
;
}
int
scale_denom
=
1
;
if
(
flags
>
IMREAD_LOAD_GDAL
)
{
if
(
flags
&
IMREAD_GRAYSCALE_REDUCED_2
)
scale_denom
=
2
;
else
if
(
flags
&
IMREAD_GRAYSCALE_REDUCED_4
)
scale_denom
=
4
;
else
if
(
flags
&
IMREAD_GRAYSCALE_REDUCED_8
)
scale_denom
=
8
;
}
/// set the scale_denom in the driver
decoder
->
setScale
(
scale_denom
);
/// set the filename in the driver
decoder
->
setSource
(
filename
);
decoder
->
setSource
(
filename
);
// read the header to make sure it succeeds
if
(
!
decoder
->
readHeader
()
)
...
...
@@ -296,7 +307,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
if
(
hdrtype
==
LOAD_CVMAT
)
{
matrix
=
cvCreateMat
(
size
.
height
,
size
.
width
,
type
);
temp
=
cvarrToMat
(
matrix
);
temp
=
cvarrToMat
(
matrix
);
}
else
{
...
...
@@ -307,7 +318,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
else
{
image
=
cvCreateImage
(
size
,
cvIplDepth
(
type
),
CV_MAT_CN
(
type
)
);
temp
=
cvarrToMat
(
image
);
temp
=
cvarrToMat
(
image
);
}
// read the image data
...
...
@@ -320,10 +331,9 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_d
return
0
;
}
int
testdecoder
=
decoder
->
setScale
(
scale_denom
);
// if decoder is JpegDecoder then testdecoder will be 1
if
(
(
scale_denom
>
1
)
&
(
testdecoder
>
1
)
)
if
(
decoder
->
setScale
(
scale_denom
)
>
1
)
// if decoder is JpegDecoder then decoder->setScale always returns 1
{
resize
(
*
mat
,
*
mat
,
Size
(
size
.
width
/
scale_denom
,
size
.
height
/
scale_denom
)
);
resize
(
*
mat
,
*
mat
,
Size
(
size
.
width
/
scale_denom
,
size
.
height
/
scale_denom
)
);
}
return
hdrtype
==
LOAD_CVMAT
?
(
void
*
)
matrix
:
...
...
@@ -421,27 +431,6 @@ Mat imread( const String& filename, int flags )
return
img
;
}
/**
* Read an image and resize it
*
* This function merely calls the actual implementation above and returns itself.
*
* @param[in] filename File to load
* @param[in] flags Flags you wish to set.
* @param[in] scale_denom Scale value
*/
Mat
imread_reduced
(
const
String
&
filename
,
int
flags
,
int
scale_denom
)
{
/// create the basic container
Mat
img
;
/// load the data
imread_
(
filename
,
flags
,
LOAD_MAT
,
&
img
,
scale_denom
);
/// return a reference to the data
return
img
;
}
/**
* Read a multi-page image
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment