Aperture operators
Reference: Hirata Jr, Roberto, et al. "Aperture filters: theory, application, and multiresolution analysis." Advances in Nonlinear Signal and Image Processing (2006): 15-45.
The image transforms learned in TRIOS are locally defined inside a small neighborhood around each pixel. Aperture transforms also put a vertical window of size \(k\) centered on the gray-level value of the pixel. Given a window W with dimensions \(m\times n\), Aperture subtracts the center pixel value from all points in the window, saturating at a value \(k\) and \(-k\).
Aperture is very useful when dealing with gray-level problems where changes in brightness do not affect the output image. The most notable application of Aperture was in conjunction with Two Level and NILC to do retinal vessel segmentation in the DRIVE dataset (as reported in this thesis, which obtained accuracies of about \(94.4\)% ).
Download the DRIVE dataset
and modify the drive_location
variable to use the code below. It takes about
2 minutes to run on a regular desktop machine and represents a very simple
use case for Aperture.
# file docs/examples/methods/aperture.py
from trios.classifiers import SKClassifier
from sklearn.tree import DecisionTreeClassifier
from trios.feature_extractors import Aperture
import trios
import numpy as np
import trios.shortcuts.persistence as p
drive_location = '/media/igor/Data1/datasets/drive'
training = trios.Imageset([
('%s/training/images/%2d_training.tif'%(drive_location, i),
'%s/training/1st_manual/%2d_manual1.gif'%(drive_location, i),
'%s/training/mask/%2d_training_mask.gif'%(drive_location, i))
for i in range(21, 41)])
testset = trios.Imageset([
('%s/test/images/%02d_test.tif'%(drive_location, i),
'%s/test/1st_manual/%02d_manual1.gif'%(drive_location, i),
'%s/test/mask/%02d_test_mask.gif'%(drive_location, i))
for i in range(1, 21)])
if __name__ == '__main__':
win = np.ones((9, 9), np.uint8)
ap = Aperture(win, 10, mul=0.5)
op = trios.WOperator(win, SKClassifier(DecisionTreeClassifier()), ap)
print('Training')
op.train(training[:2]) # only two images to speed up
print('Evaluating')
print('Accuracy:', 1 - op.eval(testset[:2])) # only two images to speed up
Accuracy: 0.9081394727942615