Skip to content

2b) Convolutional Neural Network Classification

Ivan Ivanov edited this page Sep 30, 2019 · 8 revisions

Description:

CNN classification is based on pre-trained state-of-the-art tile-based CNNs (Figure 1). We reformulate our problem of generating boundary likelihoods for MCG lines to be solvable by a tile-based CNN as follows: at first, image tiles of 224 x 224 pixels centered on an MCG line are cropped from the orthoimage. 224 x 224 x 3 is the standard size of images required by the used CNN. A tile is labelled as boundary if the center pixel covering an MCG line overlaps with the cadastral reference buffer. A tile is created every 5 m along an MCG line. Decreasing this distance would increase overlap and thus redundancy of image content per tile. Increasing this distance would reduce the number of tiles and thus the number of training data. With these settings, we generate 1.5 million tiles surrounding MCG pixels of which 5% are labelled as boundary and 95% as not boundary. After training, the CNN predicts boundary likelihoods for unseen testing areas. The likelihoods of all tiles per MCG line are averaged based on the 97th percentile. This value aligns with the distribution of boundary and not boundary lines in the training data. We use a pre-trained CNN architecture. We apply transfer learning by adding additional trainable layers: a global spatial average pooling layer, a fully connected layer with rectified linear unit (ReLU) activation, a dropout layer, and a logistic layer with softmax activation. Only these last layers are trainable. The classification is based on the open-source Keras CNN implementation.

Figure 1: Boundary line classification based on Random Forest (RF) to derive boundary likelihoods for MCG lines.

Input:

  • image segmentation lines without attributes (.shp)
  • cadastral reference lines (.shp)
  • RGB orthoimage raster (.tif)

Output:

  • image segmentation lines with boundary likelihood as attribute (.shp)

Steps:

  1. Prepare training data
  2. Train and apply classifier
  3. Predict boundary likelihoods


1. Prepare training data

Goal:

Create boundary and no boundary tiles for training data.

  • boundary = tile has MCG line and cadastral reference line in center pixel
  • no boundary = 0 : tile has MCG line, but no cadastral reference line in center pixel

Input:

  • image segmentation lines (.shp)
  • cadastral reference lines (.shp)
  • RGB orthoimage raster (.tif)

Output:

  • image raster tiles of 224x224x3 sorted into boundary and no boundary folder (.tif)

Steps:

  • Buffer cadastral reference lines

  • Rasterize image segmentation lines (.shp) and buffered cadastral reference lines (.shp)

  • Merge input data to a 5-band-raster

    • RGB red channel

    • RGB green channel

    • RGB blue channel

    • buffered cadastral reference

    • image segmentation

      merge_command = ["python", "gdal_merge.py", "-o", "5bandraster.tif", "orthoimage_red.tif", "orthoimage_green.tif", "orthoimage_blue.tif", "cadastral_reference_buffered.tif", "MCG_lines.tif","-separate"]

  • Convert MCG lines to points

    • QGIS: Points Along Geometry

  • Create raster tiles around each MCG point and save to boundary and no boundary folders



2. Train and apply classifier

Goal:

To create a classifier model based on training data and apply it to testing data.

Input:

  • 5-band image tiles raster (.tif) for training and testing

Output:

  • 5-band image tiles raster (.tif) for testing with prediction

Steps:



3. Predict boundary likelihoods

Goal:

To merge boundary likelihood prediction for all tiles per MCG line.

Input:

  • 5-band image tiles raster (.tif) for testing with prediction
  • image segmentation lines withou attributes (.shp)

Output:

  • image segmentation lines with predicted boundary label (.shp)

Steps:



General notes:

The wiki for the CNN classification is less detailed compared to all other wiki sections. We recommend using RF classification, as it is requires less computing power and memory. However, the CNN classification showed slightly better accuracy results, which are described in detail in a scientific publication that is currently under review.



References:

  • The GIS used for this wiki is the open source QGIS.