本文整理汇总了C++中BinaryImage::Sauvola方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryImage::Sauvola方法的具体用法?C++ BinaryImage::Sauvola怎么用?C++ BinaryImage::Sauvola使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryImage
的用法示例。
在下文中一共展示了BinaryImage::Sauvola方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
PngImage Png;
Png.Read("./cballs.png");
GrayImage GrayOriginal, GrayBlured, GrayAdjusted;
// Convert original PNG to gray-level image
GrayOriginal.Convert(Png);
// Blur PNG image
FastGaussianBlur::Blur<3>(Png, 4.0);
Png.Write("./cballs_blured.png");
// Convert Blured PNG image to gray-level image
GrayBlured.Convert(Png);
GrayAdjusted.CopyFrom(GrayBlured);
// Adjust color
GrayAdjusted.AdjustColor(1.5, -250);
Png.Write(GrayOriginal, "./cballs_gray.png");
Png.Write(GrayBlured, "./cballs_grayblured.png");
Png.Write(GrayAdjusted, "./cballs_grayadjusted.png");
BinaryImage Bin;
// Example of Otsu binarization
Bin.Otsu(GrayAdjusted);
Png.Write(Bin, "./cballs_otsu.png");
// Example of Niblack binarization
Bin.Niblack(GrayAdjusted, 150, 1.5);
Png.Write(Bin, "./cballs_niblack.png");
// Example of Sauvola binarization
Bin.Sauvola(GrayAdjusted, 20, 0.2);
Png.Write(Bin, "./cballs_sauvola.png");
Png.Read("./cballs.png");
Cluster Objects;
// Clusterize white objects (glowing white balls)
uint16_t ClusterAmount = Objects.Clusterize(Bin);
for (int i = 0; i < ClusterAmount; ++i)
{
const ClusterItem &item = Objects.GetCluster(i);
Png.DrawCross(item.Cx, item.Cy, 20, PixelType::RGB24(0,255,0));
}
Png.Write("./cballs_clusterized.png");
Png.Read("./cballs.png");
PngImage Png2;
Png2.Read("./cballs.png");
AffineTransformation Affine;
AffineTransformation Affine2;
GrayImage Gray1, Gray2;
Gray1.Convert(Png);
//Affine.Shift(20, 50);
Affine.RotateDeg(22.5);
Affine2.Scale(2, 2);
//Affine.Scale(0.5, 0.5);
Affine.Transform(Affine2);
AffineTransformationTable AffineTable;
AffineTable.Calculate(Gray1.GetWidth(), Gray1.GetHeight(), Affine, true);
AffineTable.Apply<InterpolationType::NearestNeighbour>(Gray1, Gray2);
Png.Write(Gray2, "./cballs_affine.png");
PngImage testPng;
testPng.Read("./cballs.png");
GrayImage testGray, testGray2;
testGray.Convert(testPng);
testGray2.CopyFrom(testGray);
Sobel sobel;
sobel.Calculate(testGray);
const GenericImage<GenericPixel<int32_t , 1>> *magn = sobel.GetMagnitude();
int32_t min_ = min(*magn);
int32_t max_ = max(*magn);
int32_t factor = max_ - min_;
printf("%d %d %d\n", min_, max_, factor);
auto it_src = magn->begin();
auto it_dst = testGray.begin();
for (; it_src != magn->end(); ++it_src, ++it_dst)
{
if (factor > 0)
{
int32_t p = it_src[0];
p -= min_;
it_dst[0] = (unsigned char) min(255, max(0, (255 * p) / factor));
}
else
{
//.........这里部分代码省略.........