forked from spmallick/learnopencv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* OpenCV SimpleBlobDetector Example | ||
* | ||
* Copyright 2015 by Satya Mallick <spmallick@gmail.com> | ||
* | ||
*/ | ||
|
||
#include "opencv2/opencv.hpp" | ||
|
||
using namespace cv; | ||
using namespace std; | ||
|
||
string type2str(int type) { | ||
string r; | ||
|
||
uchar depth = type & CV_MAT_DEPTH_MASK; | ||
|
||
switch ( depth ) { | ||
case CV_8U: r = "8U"; break; | ||
case CV_8S: r = "8S"; break; | ||
case CV_16U: r = "16U"; break; | ||
case CV_16S: r = "16S"; break; | ||
case CV_32S: r = "32S"; break; | ||
case CV_32F: r = "32F"; break; | ||
case CV_64F: r = "64F"; break; | ||
default: r = "User"; break; | ||
} | ||
|
||
return r; | ||
} | ||
|
||
|
||
int main( int argc, char** argv ) | ||
{ | ||
// Read 8-bit grayscale image | ||
Mat im = imread("earth-16-bit-per-channel.png", IMREAD_GRAYSCALE); | ||
cout << "flags : IMREAD_GRAYSCALE" << endl; | ||
cout << "Number of Channels : " << im.channels() << ", depth : " << type2str(im.depth()) << endl << endl; | ||
|
||
// Read 8-bit color image | ||
im = imread("earth-16-bit-per-channel.png", IMREAD_COLOR); | ||
cout << "flags : IMREAD_COLOR" << endl; | ||
cout << "Number of Channels : " << im.channels() << ", depth : " << type2str(im.depth()) << endl << endl; | ||
|
||
// Read 16-bit color image | ||
im = imread("earth-16-bit-per-channel.png", IMREAD_ANYCOLOR | IMREAD_ANYDEPTH ); | ||
cout << "flags : IMREAD_ANYCOLOR | IMREAD_ANYDEPTH" << endl; | ||
cout << "Number of Channels : " << im.channels() << ", depth : " << type2str(im.depth()) << endl << endl; | ||
|
||
// Read transparent PNG / TIFF image | ||
im = imread("earth-16-bit-per-channel.png", IMREAD_UNCHANGED); | ||
cout << "flags : IMREAD_UNCHANGED" << endl; | ||
cout << "Number of Channels : " << im.channels() << ", depth : " << type2str(im.depth()) << endl << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/python | ||
import cv2 | ||
|
||
# Read 8-bit grayscale image | ||
im = cv2.imread("earth-16-bit-per-channel.png", cv2.IMREAD_GRAYSCALE) | ||
print "flags : cv2.IMREAD_GRAYSCALE" | ||
print "Size %s, type %s\n" % (im.shape,im.dtype) | ||
|
||
# Read 8-bit color image | ||
im = cv2.imread("earth-16-bit-per-channel.png", cv2.IMREAD_COLOR) | ||
print "flags : cv2.IMREAD_COLOR" | ||
print "Size %s, type %s\n" % (im.shape,im.dtype) | ||
|
||
# Read 16-bit color image | ||
im = cv2.imread("earth-16-bit-per-channel.png", cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH ) | ||
print "flags : cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH" | ||
print "Size %s, type %s\n" % (im.shape,im.dtype) | ||
|
||
# Read transparent PNG / TIFF image | ||
im = cv2.imread("earth-16-bit-per-channel.png", cv2.IMREAD_UNCHANGED) | ||
print "flags : cv2.IMREAD_UNCHANGED" | ||
print "Size %s, type %s\n" % (im.shape,im.dtype) |