7  Feature Engineering

7.1 Introduction

Feature engineering is the art and science of extracting meaningful representations from raw image data that can be effectively used as inputs to deep learning networks. Unlike traditional machine learning where hand-crafted features were paramount, deep learning networks theoretically learn their own features through multiple layers. However, intelligently engineered features remain valuable for improving model performance, interpretability, and computational efficiency. This chapter revisits classical feature extraction methods through the lens of deep learning, demonstrating how to create feature maps and tensor representations suitable for neural network ingestion.


7.2 Revisiting Sobel Filtering: Building Feature Maps for Neural Networks

7.2.1 Section Overview

The Sobel operator, a classical edge detection filter discussed in earlier chapters, takes on new significance when viewed as a feature engineering technique for deep learning. Rather than simply detecting edges for visualization, we now consider how Sobel-based feature maps can be stacked into tensor structures that serve as input layers or intermediate representations within neural networks.

7.2.2 Key Topics

  • Sobel as a feature extractor: Understanding gradient-based edge detection as feature generation rather than edge detection
  • Multi-directional Sobel filtering: Computing Sobel responses in orthogonal directions (x and y) and combining them into feature representations
  • Magnitude and orientation maps: Creating feature channels that capture both the strength and direction of intensity changes
  • Tensor construction: Stacking Sobel responses into multi-channel feature tensors suitable for network input
  • Implementation considerations: Normalization, padding, and efficient tensor operations for large datasets

7.2.3 Pedagogical Value

Students will understand how classical image processing kernels can be reinterpreted as learnable or fixed feature extractors, forming a conceptual bridge between hand-crafted features and learned representations.


7.3 Gabor Filtering for Multi-Directional Feature Extraction

7.3.1 Section Overview

Gabor filters are biologically motivated filters that respond to spatial frequencies and orientations present in images. They provide an elegant mathematical framework for extracting oriented texture and edge information at multiple scales and directions, making them excellent feature generators for deep learning applications.

7.3.2 Key Topics

  • Gabor filter mathematics: The Gaussian envelope modulated by a sinusoidal plane wave
  • Filter parameters: Wavelength, orientation, phase, and aspect ratio of the Gaussian envelope
  • Creating filter banks: Designing comprehensive sets of Gabor filters across multiple scales and orientations
  • Feature map generation: Convolving images with Gabor filter banks to create multi-channel feature representations
  • Texture analysis: Using Gabor responses to characterize local texture properties
  • Integration with neural networks: Using Gabor-filtered features as fixed or learned initialization layers

7.3.3 Pedagogical Value

Gabor filtering introduces students to filters with explicit interpretability—each filter responds to specific frequencies and orientations—providing a transparent alternative to black-box learned convolutional filters.


7.4 Gray Level Co-Occurrence Matrix (GLCM) Features

7.4.1 Section Overview

The Gray Level Co-Occurrence Matrix (GLCM) is a statistical approach to texture analysis that captures spatial relationships between pixel values. GLCM-derived features provide measures of contrast, correlation, energy, and homogeneity that can effectively characterize textural properties for classification and regression tasks in deep learning.

7.4.2 Key Topics

  • GLCM construction: Building co-occurrence matrices for given offsets and directions
  • Offset and direction parameters: How to systematically sample spatial relationships at various distances and angles
  • Normalization: Transforming raw co-occurrence counts into probability distributions
  • Haralick features: Computing statistical measures from normalized GLCMs including contrast, dissimilarity, homogeneity, energy, correlation, and angular second moment
  • Multi-directional GLCM analysis: Averaging features across multiple directions to achieve rotation invariance
  • Computational efficiency: Optimizing GLCM computation for large-scale texture feature extraction
  • Feature vectorization: Organizing GLCM-derived features into vectors suitable for network input

7.4.3 Pedagogical Value

GLCM features demonstrate how statistical summaries of local structure can capture meaningful texture information, bridging classical texture analysis and modern deep learning approaches.


7.5 Multiscale Features

7.5.1 Section Overview

Real-world images contain meaningful structures at multiple scales. Multiscale feature extraction creates a hierarchy of feature maps at different resolutions, enabling networks to recognize both fine details and coarse structures. This approach mirrors the hierarchical feature learning inherent in deep convolutional networks.

7.5.2 Key Topics

  • Image pyramids: Constructing Gaussian and Laplacian pyramids for multi-resolution analysis
  • Multiscale edge and curvature detection: Computing Sobel, Laplacian, and Hessian responses at multiple scales
  • Feature map aggregation: Combining feature representations across scales into unified tensors
  • Blob detection: Identifying blob-like structures (large curvature in all directions) at their characteristic scales
  • Ridge and saddle point detection: Extracting line-like (large curvature in one direction) and saddle-like features
  • Scale selection: Determining which scales are most relevant for a given application
  • Computational considerations: Efficient pyramid construction and feature computation

7.5.3 Pedagogical Value

Multiscale analysis highlights the importance of considering image structure across different resolutions, a principle fundamental to both classical computer vision and deep learning architectures.


7.6 Pyradiomics: Advanced Radiomics Feature Engineering

7.6.1 Section Overview

Pyradiomics is a comprehensive framework for extracting advanced radiomics features from medical images. Originally developed for oncology, it provides a systematic and standardized approach to extracting hundreds of features characterizing image intensity, shape, and texture properties. This section demonstrates how to leverage established radiomics pipelines for feature engineering in deep learning contexts.

7.6.2 Key Topics

  • Pyradiomics framework overview: Architecture, design principles, and standardization advantages
  • Image preprocessing pipeline: Resample, normalize, and mask operations standardized across datasets
  • First-order statistics: Histogram-based features capturing intensity distributions
  • Shape features: Geometric properties including volume, surface area, elongation, and flatness
  • Texture filters: Integration with Gabor, Laplacian of Gaussian (LoG), Wavelet, and Square filters
  • GLCM-derived texture features: Standardized radiomics implementation of co-occurrence matrix analysis
  • Run-length and size-zone matrix features: Capturing spatial patterns of gray level runs and connected regions
  • Feature extraction workflow: Complete end-to-end pipeline from medical image to feature vector
  • Integration with deep learning: Using radiomics features as additional input channels or auxiliary targets
  • Standardization and reproducibility: Ensuring consistent feature computation across studies and implementations

7.6.3 Pedagogical Value

Pyradiomics represents state-of-the-art feature engineering for medical imaging, showing students how domain expertise and standardization practices enable reproducible and interpretable machine learning pipelines that complement deep learning.


7.7 K-Means Clustering for Feature Quantization and Codebook Learning

7.7.1 Section Overview

K-means clustering provides an elegant approach to learning a compact representation (codebook) of image features. By clustering local features or filter responses, K-means creates a discrete vocabulary of prototypical patterns that can be used for feature quantization, bag-of-words representations, and deep learning feature pooling strategies.

7.7.2 Key Topics

Fundamentals of K-Means Clustering

  • Algorithm overview: Iterative partitioning of data into K clusters minimizing within-cluster variance
  • Initialization strategies: Random initialization, K-means++ smart initialization, and seeding from domain knowledge
  • Convergence criteria: Monitoring cluster assignment changes and centroid movements
  • Selecting the number of clusters: Elbow method, silhouette analysis, and domain-specific considerations
  • Computational complexity: Complexity analysis and scalability to large feature sets

Learning Visual Codebooks

  • Feature pooling regions: Dividing images into spatial regions (e.g., using spatial pyramids)
  • Local feature extraction: Computing descriptors at keypoints or dense sampling locations
  • Codebook training: Learning cluster centers from features extracted from training images
  • Quantization and encoding: Assigning local features to nearest codebook entries
  • Histogram construction: Creating bag-of-words representations by counting feature occurrences

Applications in Image Classification

  • Spatial pyramid matching: Hierarchical codebook matching across image pyramids
  • Bag-of-visual-words classification: Training classifiers on quantized feature representations
  • Combination with other features: Concatenating K-means derived features with other engineered features

Integration with Deep Learning

  • Codebook-enhanced network inputs: Augmenting raw pixels or learned features with quantized representations
  • Unsupervised pretraining: Using K-means to initialize network weights or learn representations
  • Interpretability through codebooks: Understanding what visual patterns networks respond to
  • Computational efficiency: Reducing feature dimensionality through quantization and pooling
  • Generalization improvement: How quantization acts as a regularization mechanism

Implementation and Practical Considerations

  • Feature normalization: Standardizing feature distributions before clustering
  • Memory efficiency: Processing large feature collections in batches
  • Algorithm variants: Mini-batch K-means, K-means++ and approximate methods
  • Parameter tuning: Finding optimal cluster counts and convergence thresholds for specific domains
  • Evaluation metrics: Silhouette score, Davies-Bouldin index, and task-specific performance measures

7.7.3 Pedagogical Value

K-means clustering bridges unsupervised learning and feature engineering, demonstrating how to create interpretable, discrete feature representations that complement continuous deep learning features. This section emphasizes the value of quantization as both a practical tool and a source of regularization.


7.8 Summary and Synthesis

Feature engineering for deep learning is not a relic of pre-deep-learning era, but rather an essential tool for building effective, interpretable, and efficient models. The techniques presented in this chapter—from classical Sobel filtering to sophisticated radiomics frameworks to unsupervised codebook learning—provide a comprehensive toolkit for extracting meaningful representations from images.

The key insight is that these engineered features and learned features are complementary. Engineered features bring interpretability and domain knowledge, while learned features adapt to specific tasks. The most effective deep learning pipelines often combine both approaches strategically.


7.9 Exercises and Projects

[Exercises and projects will be detailed in subsequent edits, covering practical implementation, comparison of feature extraction methods, and integration strategies with neural networks.]


7.10 Further Reading

[References to key papers on Gabor filtering, GLCM texture analysis, multiscale image analysis, Pyradiomics publications, and K-means clustering in computer vision will be provided in subsequent edits.]

Sign in to save progress

0 / 0

📚 Gradebook

Loading…

Sign in to save progress