Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/core/core.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/objdetect/objdetect.hpp>

#include <limits.h>

#include <math.h>

#include <iostream>

using namespace std;

using namespace cv;

Mat LBP(Mat src_image)

{

bool value=true;

`Mat Image(src_image.rows, src_image.cols, CV_8UC1);`

 `Mat lbp(src_image.rows, src_image.cols, CV_8UC1);`

`if (src_image.channels() == 3)`

    `cvtColor(src_image, Image, CV_BGR2GRAY);`

`unsigned center = 0;`

`unsigned center_lbp = 0;`

for (int row = 1; row < Image.rows-1; row++)
{
    for (int col = 1; col < Image.cols-1; col++)
    {
        center = Image.at<uchar>(row, col);
        center_lbp = 0;

        if (center <= Image.at<uchar>(row-1, col-1))
            center_lbp += 1;

        if (center <= Image.at<uchar>(row-1, col))
            center_lbp += 2;//2

        if (center <= Image.at<uchar>(row-1, col+1))
            center_lbp += 4;//4

        if (center <= Image.at<uchar>(row, col+1 ))
            center_lbp += 8;//8

        if (center <= Image.at<uchar>(row+1, col+1))
            center_lbp += 16;//16

        if (center <= Image.at<uchar>(row+1, col))
            center_lbp += 32;//32

        if (center <= Image.at<uchar>(row+1,col-1))
            center_lbp += 64;//64

        if (center <= Image.at<uchar>(row,col-1))
            center_lbp += 128;//128
        lbp.at<uchar>(row, col) = center_lbp;
    }
}

if(value == true)

        `{

          `namedWindow( "image LBP", CV_WINDOW_FREERATIO);`

          `imshow("image_LBP", lbp);'

            'imwrite("/root/Desktop/LBP.jpg",lbp);'

          'waitKey(0);'

          'imshow("grayscale",Image);'

          waitKey(0);
        }

        else
        {
          cv::destroyWindow("image LBP");
          cv::destroyWindow("grayscale");
        }

return lbp;

}`

int main()

{

`string filename="1.jpg";`
 `Mat frame1;'
  `frame1= imread("/root/Desktop/"+filename);`
   `LBP(frame1);`
}![image description](/upfiles/14818893533562383.jpg)(/upfiles/14818893432706862.jpg)

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/core/core.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/objdetect/objdetect.hpp>

#include <limits.h>

#include <math.h>

#include <iostream>

using namespace std;

using namespace cv;

Mat LBP(Mat src_image)

{

bool value=true;

`Mat Image(src_image.rows, src_image.cols, CV_8UC1);`

 `Mat lbp(src_image.rows, src_image.cols, CV_8UC1);`

`if (src_image.channels() == 3)`

    `cvtColor(src_image, Image, CV_BGR2GRAY);`

`unsigned center = 0;`

`unsigned center_lbp = 0;`

for (int row = 1; row < Image.rows-1; row++)
{
    for (int col = 1; col < Image.cols-1; col++)
    {
        center = Image.at<uchar>(row, col);
        center_lbp = 0;

        if (center <= Image.at<uchar>(row-1, col-1))
            center_lbp += 1;

        if (center <= Image.at<uchar>(row-1, col))
            center_lbp += 2;//2

        if (center <= Image.at<uchar>(row-1, col+1))
            center_lbp += 4;//4

        if (center <= Image.at<uchar>(row, col+1 ))
            center_lbp += 8;//8

        if (center <= Image.at<uchar>(row+1, col+1))
            center_lbp += 16;//16

        if (center <= Image.at<uchar>(row+1, col))
            center_lbp += 32;//32

        if (center <= Image.at<uchar>(row+1,col-1))
            center_lbp += 64;//64

        if (center <= Image.at<uchar>(row,col-1))
            center_lbp += 128;//128
        lbp.at<uchar>(row, col) = center_lbp;
    }
}

if(value == true)

        `{

          `namedWindow( "image LBP", CV_WINDOW_FREERATIO);`

          `imshow("image_LBP", lbp);'

            'imwrite("/root/Desktop/LBP.jpg",lbp);'

          'waitKey(0);'

          'imshow("grayscale",Image);'

          waitKey(0);
        }

        else
        {
          cv::destroyWindow("image LBP");
          cv::destroyWindow("grayscale");
        }

return lbp;

}`

int main()

{

`string filename="1.jpg";`
 `Mat frame1;'
  `frame1= imread("/root/Desktop/"+filename);`
   `LBP(frame1);`
}![image description](/upfiles/14818893533562383.jpg)(/upfiles/14818893432706862.jpg)
}

image description image description

click to hide/show revision 3
No.3 Revision

updated 2016-12-16 06:16:50 -0600

berak gravatar image

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/core/core.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/objdetect/objdetect.hpp>

#include <limits.h>

#include <math.h>

#include <iostream>

<opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/objdetect/objdetect.hpp> #include <limits.h> #include <math.h> #include <iostream> using namespace std;

std; using namespace cv;

cv; Mat LBP(Mat src_image)

{

src_image) { bool value=true;

`Mat value=true;
    Mat Image(src_image.rows, src_image.cols, CV_8UC1);`

 `Mat CV_8UC1);
    Mat lbp(src_image.rows, src_image.cols, CV_8UC1);`

`if CV_8UC1);

    if (src_image.channels() == 3)`

    `cvtColor(src_image, 3)
        cvtColor(src_image, Image, CV_BGR2GRAY);`

`unsigned CV_BGR2GRAY);

    unsigned center = 0;`

`unsigned 0;
    unsigned center_lbp = 0;`

0;

    for (int row = 1; row < Image.rows-1; row++)
 {
     for (int col = 1; col < Image.cols-1; col++)
     {
         center = Image.at<uchar>(row, col);
         center_lbp = 0;

         if (center <= Image.at<uchar>(row-1, col-1))
             center_lbp += 1;

         if (center <= Image.at<uchar>(row-1, col))
             center_lbp += 2;//2

         if (center <= Image.at<uchar>(row-1, col+1))
             center_lbp += 4;//4

         if (center <= Image.at<uchar>(row, col+1 ))
             center_lbp += 8;//8

         if (center <= Image.at<uchar>(row+1, col+1))
             center_lbp += 16;//16

         if (center <= Image.at<uchar>(row+1, col))
             center_lbp += 32;//32

         if (center <= Image.at<uchar>(row+1,col-1))
             center_lbp += 64;//64

         if (center <= Image.at<uchar>(row,col-1))
             center_lbp += 128;//128
         lbp.at<uchar>(row, col) = center_lbp;
     }
    }

    if(value == true)
    {
        namedWindow( "image LBP", CV_WINDOW_FREERATIO);
        imshow("image_LBP", lbp);'
        imwrite("/root/Desktop/LBP.jpg",lbp);
        waitKey(0);
        imshow("grayscale",Image);
        waitKey(0);
    }
    else
    {
      cv::destroyWindow("image LBP");
      cv::destroyWindow("grayscale");
    }

    return lbp;

}

int main()
{

    string filename="1.jpg";
    Mat frame1;
    frame1= imread("/root/Desktop/"+filename);
    LBP(frame1);
}

if(value == true)

        `{

          `namedWindow( "image LBP", CV_WINDOW_FREERATIO);`

          `imshow("image_LBP", lbp);'

            'imwrite("/root/Desktop/LBP.jpg",lbp);'

          'waitKey(0);'

          'imshow("grayscale",Image);'

          waitKey(0);
        }

        else
        {
          cv::destroyWindow("image LBP");
          cv::destroyWindow("grayscale");
        }

return lbp;

}`

int main()

{

`string filename="1.jpg";`
 `Mat frame1;'
  `frame1= imread("/root/Desktop/"+filename);`
   `LBP(frame1);`
}

image description image description

click to hide/show revision 4
No.4 Revision

updated 2016-12-16 08:27:19 -0600

berak gravatar image
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <limits.h>
#include <math.h>
#include <iostream>


using namespace std;
using namespace cv;

Mat LBP(Mat src_image)
{
    bool value=true;
    Mat Image(src_image.rows, src_image.cols, CV_8UC1);
    Mat lbp(src_image.rows, src_image.cols, CV_8UC1);

    if (src_image.channels() == 3)
        cvtColor(src_image, Image, CV_BGR2GRAY);

    unsigned center = 0;
    unsigned center_lbp = 0;

    for (int row = 1; row < Image.rows-1; row++)
    {
        for (int col = 1; col < Image.cols-1; col++)
        {
            center = Image.at<uchar>(row, col);
            center_lbp = 0;

            if (center <= Image.at<uchar>(row-1, col-1))
                center_lbp += 1;

            if (center <= Image.at<uchar>(row-1, col))
                center_lbp += 2;//2

            if (center <= Image.at<uchar>(row-1, col+1))
                center_lbp += 4;//4

            if (center <= Image.at<uchar>(row, col+1 ))
                center_lbp += 8;//8

            if (center <= Image.at<uchar>(row+1, col+1))
                center_lbp += 16;//16

            if (center <= Image.at<uchar>(row+1, col))
                center_lbp += 32;//32

            if (center <= Image.at<uchar>(row+1,col-1))
                center_lbp += 64;//64

            if (center <= Image.at<uchar>(row,col-1))
                center_lbp += 128;//128
            lbp.at<uchar>(row, col) = center_lbp;
        }
    }

    if(value == true)
    {
        namedWindow( "image LBP", CV_WINDOW_FREERATIO);
        imshow("image_LBP", lbp);'
lbp);
        imwrite("/root/Desktop/LBP.jpg",lbp);
        waitKey(0);
        imshow("grayscale",Image);
        waitKey(0);
    }
    else
    {
      cv::destroyWindow("image LBP");
      cv::destroyWindow("grayscale");
    }

    return lbp;

}

int main()
{
     string filename="1.jpg";
    Mat frame1;
    frame1= imread("/root/Desktop/"+filename);
    LBP(frame1);
}

image description image description