1 | initial version |
This C++ code splits
the Lab image into the separate channels.
#include <iostream>
using namespace std;
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
int main(void)
{
Mat img = imread("star.png", 1);
if (img.empty())
{
cout << "Could not read image file." << endl;
return 1;
}
Mat Lab;
Mat Lab_channels[3];
cvtColor(img, Lab, COLOR_BGR2Lab);
split(Lab, Lab_channels);
threshold(Lab_channels[0], Lab_channels[0], 127, 255, THRESH_OTSU);
return 0;
}
2 | No.2 Revision |
This C++ code splits
the Lab image into the separate channels.
#include <iostream>
using namespace std;
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
int main(void)
{
Mat img = imread("star.png", 1);
if (img.empty())
{
cout << "Could not read image file." << endl;
return 1;
}
Mat Lab;
Mat Lab_channels[3];
cvtColor(img, Lab, COLOR_BGR2Lab);
split(Lab, Lab_channels);
threshold(Lab_channels[0], Lab_channels[0], 127, 255, THRESH_OTSU);
return 0;
}
This C++ code uses extractChannel to get just the first channel (channel 0).
#include <iostream>
using namespace std;
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
int main(void)
{
Mat img = imread("star.png", 1);
if (img.empty())
{
cout << "Could not read image file." << endl;
return 1;
}
Mat Lab;
Mat Lab_channel_0;
cvtColor(img, Lab, COLOR_BGR2Lab);
extractChannel(Lab, Lab_channel_0, 0);
threshold(Lab_channel_0, Lab_channel_0, 127, 255, THRESH_OTSU);
return 0;
}
3 | No.3 Revision |
This C++ code splits
the Lab image into the separate channels.
#include <iostream>
using namespace std;
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
int main(void)
{
Mat img = imread("star.png", 1);
if (img.empty())
{
cout << "Could not read image file." << endl;
return 1;
}
Mat Lab;
Mat Lab_channels[3];
cvtColor(img, Lab, COLOR_BGR2Lab);
split(Lab, Lab_channels);
threshold(Lab_channels[0], Lab_channels[0], 127, 255, THRESH_OTSU);
return 0;
}
This C++ code uses extractChannel extractChannel
to get just the first channel (channel 0).
#include <iostream>
using namespace std;
#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world340.lib")
int main(void)
{
Mat img = imread("star.png", 1);
if (img.empty())
{
cout << "Could not read image file." << endl;
return 1;
}
Mat Lab;
Mat Lab_channel_0;
cvtColor(img, Lab, COLOR_BGR2Lab);
extractChannel(Lab, Lab_channel_0, 0);
threshold(Lab_channel_0, Lab_channel_0, 127, 255, THRESH_OTSU);
return 0;
}