Skip to content

LBP and SURF (python version)

Alexandre Yuji Kajihara edited this page Jan 25, 2024 · 3 revisions

Requirements

The extract features using LBP or SURF require the installation of OpenCV.

$ git clone https://github.com/opencv/opencv.git -b 4.8.0 --single-branch
$ git clone https://github.com/opencv/opencv_contrib.git -b 4.8.0 --single-branch
$ cmake   -D CMAKE_BUILD_TYPE=RELEASE \
          -D OPENCV_EXTRA_MODULES_PATH=/home/xandao/opencv/opencv_contrib/modules \
          -D PYTHON3_EXECUTABLE=*/bin/python3.11 \
          -D PYTHON3_LIBRARY=*/lib/libpython3.11 \
          -D PYTHON3_INCLUDE_DIR=*/include/python3.11 \
          -D PYTHON3_PACKAGES_PATH=*/lib/python3.11/site-packages \
          -D BUILD_opencv_python2=OFF \
          -D BUILD_opencv_python3=ON \
          -D INSTALL_PYTHON_EXAMPLES=OFF \
          -D INSTALL_C_EXAMPLES=OFF \
          -D OPENCV_ENABLE_NONFREE=ON \
          -D BUILD_EXAMPLES=OFF ..
$ make -j$(nproc) && sudo make install

Attention

The images must be in grayscale mode to run this code.

Run (via terminal):

  1. Clone this repository;
$ git clone https://github.com/xaaaandao/piperaceae-features
  1. Access the repository in the terminal;
$ cd pipearceae-features 
  1. Next, it shows an example of how to run a code.
$ python surf_lbp.py -i /home/xandao/pr_dataset/GRAYSCALE/specific_epithet_trusted/256/20 --contrast 2
  • The list below contains the arguments available.
Usage: surf_lbp.py [OPTIONS]

Options:
  -c, --contrast FLOAT  Value that to use in adjusting the contrast.
  -i, --input PATH      Path to images.  [required]
  -o, --output PATH     Path to store the text and CSV files.
  --help                Show this message and exit.

Run (PyCharm Professional):

  1. Clone this repository;
$ git clone https://github.com/xaaaandao/piperaceae-features
  1. Open a project;

ksnip_20240125-194929

  1. Set the folder that contains the image and other arguments;

ksnip_20240125-195736

  1. To run, press SHIFT+F10 (or run button).

ksnip_20240125-200430

Output

  • This program will create a folder called lbp or surf (depending on user choice).
    • lbp

      • lbp.txt
        • Each line contains 59 columns.
        • The last column represents the class.
      • info_lbp.csv, info_levels.csv, info_sample.csv
    • surf

      • surf.txt
        • Each line contains 128 columns.
        • The last column represents the class.
      • info_surf.csv, info_levels.csv, info_samples.csv
    • info_levels.csv and info_samples.csv are files equal between three folders.

      • It is created for each folder to facilitate the next step (identification).
      • This link contains the mean of each row.
Clone this wiki locally