E ND
TO
E ND
T RAINABLE
A CTIVE
C ONTOURS
VIA
D IFFERENTIABLE R ENDERING
Anonymous authors
Paper under double-blind review
A BSTRACT
We present an image segmentation method that iteratively evolves a polygon.
At each iteration, the vertices of the polygon are displaced based on the local value of a 2D shift map that is inferred from the input image via an encoder-decoder architecture.
The main training loss that is used is the difference between the polygon shape and the ground truth segmentation mask.
The network employs a neural renderer to create the polygon from its vertices, making the process fully differentiable.
We demonstrate that our method outperforms the state of the art segmentation networks and deep active contour solutions in a variety of benchmarks, including medical imaging and aerial images
I NTRODUCTION
The importance of automatic segmentation methods is growing rapidly in a variety of ﬁelds, such as medicine, autonomous driving and satellite image analysis, to name but a few.
In addition, with the advent of deep semantic segmentation networks, there is a growing interest in the segmentation of common objects with applications in augmented reality and seamless video editing.
Since the current semantic segmentation methods often capture the objects well, except for occasional inaccuracies along some of the boundaries, ﬁtting a curve to the image boundaries seems to be an intuitive solution.
Active contours, is a set of techniques that given an initial contour (which can be provided by an existing semantic segmentation solution) grow iteratively to ﬁt an image boundary.
Active contour may also be appropriate in cases, such as medical imaging, where the training dataset is too limited to support the usage of a high-capacity segmentation network.
Despite their potential, the classical active contours fall behind the latest semantic segmentation solutions with respect to accuracy.
The recent learning-based active contour approaches were not yet demonstrated to outperform semantic segmentation methods across both medical datasets and real world images, despite having success in speciﬁc settings.
are either non-competitive or proven to be effective in the speciﬁc settings of building segmentation.
In this work, we propose to evolve an active contour based on a 2-channel displacement ﬁeld (corresponding to 2D image coordinates) that is inferred directly and only once from the input image.
This is, perhaps, the simplest approach, since unlike the active contour solutions in literature, it does not involve and balance multiple forces, and the displacement is given explicitly.
Moreover, the architecture of the method is that of a straightforward encoder-decoder with two decoding networks.
The loss is also direct, and involves the comparison of two mostly binary images.
The tool that facilitates this explicit and direct approach is a neural mesh renderer.
It allows for the propagation of the intuitive loss, back to the displacement of the polygon vertices.
While such renderers have been discovered multiple times in the past, and were demonstrated to be powerful solutions in multiple reconstruction problems, this is the ﬁrst time, as far as we can ascertain that this tool is used for image segmentation.
Our empirical results demonstrate state of the art performance in a wide variety of benchmarks, showing a clear advantage over classical active contour methods, deep active contour methods, and modern semantic segmentation methods.
R ELATED W ORK Neural Renderers
A neural mesh renderer is a fully differential mapping from a mesh to an image.
While rendering the 3D or 2D shape given vertices, faces, and face colors is straightforward, the process involves sampling on a grid, which is non-differentiable.
One obtains differentiable rendering, by sampling in a smooth (blurred) manner (Kato et al., 2018) or by approximating the gradient based on image derivatives, as in (Loper & Black, 2014).
Such renderers allow one to BackpropogateBackpropagate the error from the obtained image back to the vertices of the mesh.
In this work we employ the mesh renderer of Kato et al.
Perhaps the earliest mesh renderer was presented by Smelyansky et al.
Recent non-mesh differential renders include the point cloud renderer of Insafutdinov & Dosovitskiy (2018) and the view-based renderer of Eslami et al.
Gkioxari et al.
(2019) use a differentiable sampler to turn a 3D mesh to a point cloud and solve the task of simultaneously segmenting a 2D image object, while performing a 3D reconstruction of that object.
This is a different image segmentation task, which unlike our setting requires a training set of 3D models and matching 2D views.
Active contours
Snakes were ﬁrst introduced by Kass et al.
and were applied in a variety of ﬁelds, such as lane tracking (Wang et al., 2004), medicine (Yushkevich et al., 2006) and image segmentation (Michailovich et al., 2007).
Active contours evolve by minimizing an energy function and moving the contour across the energy surface until it halts.
Properties, such as curvature and area of the contour, guide the shape of the contour, and terms based on the image gradients or various alternatives attract contours to edges.
Most active contour methods rely on an initial contour, which often requires a user intervention.
Variants of this method have been proposed, such as using a balloon force to encourage the contour to expand and help with bad initialization, e .
g .contours located far from objects (Kichenassamy et al., 1995; Cohen, 1991).
Kichenassamy et al.
(1995) employ gradient ﬂows, modifying the shrinking term by a function tailored to the speciﬁc attracting features.
Caselles et al.
(1997) presented the Geodesic Active Contour (GAC), where contours deform according to an intrinsic geometric measure of the image, induced by image features, such as borders.
Other methods have replaced the use of edge attraction by the minimization of the energy functional, which can be seen as a minimal partition problem (Chan & Vese, 2001; Marquez-Neila et al., 2014).
The use of learning base models coupled with active contours was presented by Rupprecht et al.
(2016), who learn to predict the displacement vector of each point on the evolving contour, which would bring it towards the closest point on the boundary of the object of interest.
This learned network relies on a local patch that is extracted per each contour vertex.
This patch moves with the vertex as the contour evolves gradually.
Our method, in contrast, predicts the displacement ﬁeld for all image locations at once.
This displacement ﬁeld is static and it is the contour which evolves.
In our method, learning is not based on a supervision in the form of the displacement to the nearest ground truth contour but on the difference of the obtained polygon from the ground truth shape.
A level-set approach for active contours has also gained popularity in the deep learning ﬁeld.
Work such as (Wang et al., 2019;
Hu et al., 2017; Kim et al., 2019) use the energy function as part of the loss in supervised models.
Though fully differentiable, the level-sets do not enjoy the simplicity of polygons and their ability to ﬁt straight structures and corners that frequently appear in man-made objects (as well as in many natural structures).
The use of polygon base snakes in neural networks, as a fully differentiable module, was presented by Marcos et al.
; Cheng et al.
(2019) in the context of building segmentation.
Building segmentation and recent active contour solutions
Semi-automatic methods for urban structure segmentation, using polygon ﬁtting, have been proposed by Wang et al.
; Sun et al.
Wang et al.
; Kaiser et al.
(2017) closed the gap for full automation, overcoming the unique challenges in building segmentation.
Marcos et al.
(2018) argued that the geometric properties, which deﬁne buildings and urban structures, are not preserved in conventional deep learning semantic segmentation methods.
Speciﬁcally, sharp corners and straight walls, are only loosely learned.
In addition, a pixel-wise model does not capture the typical closed-polygon structure of the buildings.
Considering these limitations, Marcos et al.
(2018) presented the Deep Structured Active
Contours (DSAC) approach, in order to learn a polygon representation instead of the segmentation mask.
The polygon representation of Active Contour Models (ACMs) is well-suited for building
[Figure]
boundaries, which are typically relatively simple polygons.
ACMs are usually modeled to attract to edges of the reference map, mainly the raw image, and penalize over curvature regions.
The DSAC method learns the energy surface, to which the active contour attracts.
During training, DSAC integrates gradient propagation from the ACM, through a dedicated structured-prediction loss that minimizes the Intersection-Over-Union.
Cheng et al.
(2019), extended this approach, presenting the Deep Active Ray Network (DARNet), based on a polar representation of active contours, also known as active rays models of Denzler &
Niemann (1999).
To handle the complexity of rays geometry, Cheng et al.
(2019) reparametrize the rays and compute L1 distance between the ground truth polygon, represented as rays and the predicted rays.
Furthermore, in order to handle the non-convex shapes inherit in the structures, Cheng et al.
(2019) presented the Multiple Sets of Active Rays framework, which is based on the deep watershed transform by Bai & Urtasun (2017). Castrej ´ on et al. (2017) and Acuna et al.
(2018) presented a polygonal approach for objects segmentation. Given an image patch, the methods use a recurrent neural network to predict the ground truth polygon. Acuna et al. (2018) additionally made use of graph convolution networks and a reinforcement learning approach.
Ling et al.
(2019), introduced the Curve-GCN, an interactive or fully-automated method for polygon segmentation, learning an embedding space for points, and using Graph Convolution neural networks to estimate the amount of displacement for each point.
Ling et al.
(2019) also presented the use of differentiable rendering process, using the non-differentiable
OpenGL renderer, and the method of Loper & Black (2014) for computing the ﬁrst order Tylor approximation of the derivatives.
Curve-GCN supports both polygon and spline learning, but also added supervision by learning an explicit location for each point, and edge maps.
Both DSAC and DARNet enjoy the beneﬁt of a polygon-based representation.
However, this is done using elaborate and sophisticated schemes.
Curve-GCN on the other hand, beneﬁts from the use of differentiable rendering, but suffers from a time consuming mechanism that restricts it to apply it only in the ﬁne-tuning stage.
Our method is considerably simpler due to the use of a fast differentiable renderer, and a 2-D displacement ﬁeld in the scale of the input.
It uses only ground truth masks as supervision, and two additional loss terms that are based on time-tested pulling forces from the classical active contour literature: the Balloon and Curvature terms.
M ETHOD
Our trained network includes an encoder E and decoder D .
In addition, a differential renderer R is used, as well as a triangulation procedure L .
In this work we use the Delaunay triangulation.
Let S be the set of all training images.
Given an image I ∈ R c
× h × w , an initial polygon contour P 0 is produced by an oracle A , and the faces of this shape are retrieved from a triangulation procedure L , which returns a list F of mesh faces, each a triplet of polygon vertex indices.
In many benchmarks in which the task is to segment given a Region of Interest (ROI) extracted by a detector or marked [Figure] [Figure] by a user, the oracle simply returns a ﬁxed circle in the middle of the ROI.
Fig 3 illustrates the initial contour generation process.
The contour evolves for T iterations, from P 0 to P 1 and so on until the ﬁnal shape given by P T .
It is represented by a list of k vertices P t =
[ p t 1 , p t 2 , . .
, p t k ] , where each vertex is a two dimensional coordinate.
This evolution follows a dual-channel displacement ﬁeld:
[Equation]
For every vertex j = 1 ..k , the update follows the following rule:
[Equation]
where J ( p t − 1 j ) is a 2D vector, and the operation J ( · ) denotes the sampling operation of displacement ﬁeld J , using bi-linear interpolation at the coordinates of p t − 1 j .
Coordinates which fall outside the boundaries of the image are then truncated (the following uses square brackets to refer to indexed vector elements):
[Equation]
The neural renderer, given the vertices and the faces returns the polygon shape as a mask, where all pixels inside the faces F are ones, and zero otherwise:
[Equation]
where ¯ M t is the output segmentation at iteration t .
This mask is mostly binary, except for the boundaries where interpolation occurs.
Because the used renderer works in 3D space, we project all points to 3D by setting their z axis to 1 , and use orthogonal projection.
This segmentation mask ¯ M t is compared to the ground truth mask M at each iteration, and accumulated over T iterations to obtain the segmentation loss:
[Equation]
where (cid:107) · (cid:107) 2 is the MSE loss applied to all mask values.
The curve evolution in classic active contour models is inﬂuenced by two additional forces: a ballooning force and a curvature minimizing force.
In our feed forward network, these are manifested as training losses.
The Balloon term L B , maximizes the polygon area, causing it to expand:
[Equation]
where h and w are the segmentation height and width, and x denotes a single pixel in ¯ M t .
Second, the Curvature term L K minimizes the curvature of the polygon, resulting in a more smooth form:
[Equation]
Require: { I i } ni =1 : Input images, { M i } :
Matching ground truth segmentation masks, A : Initial guess oracle, R : differential renderer, L : a triangulation procedure, k : number of vertices, T : number of iterations, λ 1 , λ 2 : a weighting parameter.
1: Initialize networks E, D 2: for multiple epochs do 3: for i =
....n do 4:
P
=
[ p 01 , p 02 , .., p 0 k ] ← A ( I i ) (cid:46) Initialize the polygon using the oracle 5:
F ← L ( P 0 ) (cid:46) Triangulation to obtain the mesh faces 6:
J ← D ( E ( I )) 7: for t = 1....
T do 8:
Let P t =
[ p t 1 , p t 2 , .., p tk ] 9: for j = 1....
k do 10: p tj ← p t − 1 j + J ( p t − 1 j ) (cid:46) Set the vertices of polygon P t 11: ¯ M t =
R ( P t , F ) (cid:46)
The polygon shape as an image 12:
L ← L + (cid:107) ¯ M t − M
[Equation]
( x )) + λ
[Equation]
[Equation]
(cid:80)
[Equation]
| p tj
[Equation]
1 − 2 p tj + p tj +1 |13:
BackpropogateBackpropagate the loss L and update E, D where the L 2 norm is computed on 2D coordinate vectors.
The complete training loss is therefore:
[Equation]
for some weighting parameter λ 1 and λ 2 .
It is applied after each evolution of the contour (and not just on the ﬁnal contour).
See Alg. 1 for a listing of the process. 3. A RCHITECTURE AND TRAINING We employ an Encoder-Decoder architecture with U-Net skip connections (C¸ic¸ek et al., 2016), which link layers of matching sizes between the encoder sub-network and the decoder sub-network, as can be seen in Fig.
The encoder part, as can be seen in Fig.
2(a), is built from blocks which are mirror-like versions of the relative decoder blocks, as can be seen in Fig. 2(b), connected by a skip connection.
An encoder block consists of (i) three sub-blocks of convolution layer followed by dropout with probability of 0.2, (ii) ReLU, (iii) batch normalization and (iv) max-pooling, to down-sample the input feature map.
The decoder blocks A decoder block consists of (i) batch normalization, (ii) ReLU, (iii) bi-linear interpolation, which up-samples the input feature map to the size of the skip connection, (iv) concatenation of the input skip connection and the output of the previous step, (v) three sub-blocks of convolution layer, followed by dropout with probability of 0 . 2 .
For the last decoder block, we omit the dropout layer, and up-sample to the input image size using bi-linear interpolation.
To get the pixel-wise probabilities, we employ the Sigmoid (logistic) activation.
For training the segmentation networks, we use the ADAM optimizer Kingma & Ba (2014) with a learning rate 0.001, batch size varies depending of input image size, for 64 × 64 we use 100, 128 × 128 we use 50.
We set λ 1 = 10 − 2 and λ 2 = 5 · 10 − 1 .
E XPERIMENTS
For evaluation, we use the common segmentation metrics of F1-score and Intersection-over-Union (IoU).
Additionally, for the buildings segmentation datasets, we use the Weighted Coverage (WCov) and Boundary F-score (BoundF), which is the averaged F1-score over thresholds from 1 to 5 pixels around the ground truth, as described by Cheng et al. [Figure] [Table] [Table]
B UILDING S EGMENTATION
We consider two publicly available datasets in order to evaluate our method, the Vaihingen (Rottensteiner et al.) dataset, which contains buildings from a German city, and the Bing Huts dataset (Marcos et al., 2018), which contains huts from a village in Tanzania.
A third dataset named TorontoCity, proposed by Marcos et al.
; Cheng et al.
(2019) is not yet publicly available (private communication, 2019).
The Vaihingen dataset consists of 168 buildings extracted from ISPRS Rottensteiner et al..
All images contain centered buildings with a very dense environment, including other structures, streets, trees and cars, which makes the task more challenging.
The dataset is divided intobuildings for training, and the remaining 68 for testing.
The image’s size is 512 × 512 × 3 , which is relatively high.
We experiment with different resizing factors during training.
The Bing Huts dataset consists of 606 images, 335 images for train and 271 images for test.
The images suffer from low spatial resolution and have the size of 64 × 64 , in contrast to the Vaihingen dataset.
We compare our method to the relevant previous works, following the evaluation process, as described in Cheng et al.
(2019), using the published test/val/train splits.
The evaluated polygons are scaled, according to the original code of Cheng et al.
For both datasets, we augment the training data (of the networks) by re-scaling in factors of [0 . 75 , 1 , 1 . 25 , 1 . 5] , and rotating by [0 , 15 , 45 , 60 , 90 , 135 , 180 , 210 , 240 , 270] degrees.
[Table]
[Table]
As can be seen in Tab.
1 our method signiﬁcantly outperforms the baseline methods on both building datasets.
Fig.
4 compares the results of our method with the leading method by Cheng et al. [Table]
4. M EDICAL I MAGING
We evaluate our method using two common mammographic mass segmentation datasets, the INBreast (Moreira et al., 2012), DDSM-BCRP (Heath et al., 1998) [Table] and a cardiac MR left ventricle segmentation datasets, the SCD (Radau et al., 2009).
For the mammographic dataset, we follow previous work and use the expert ROIs, which were manually extracted, and the same train/test split as Zhu et al.
; Li et al.
INBreast dataset consists of 116 accurately annotated masses, with mass size ranging from 15 mm 2 to 3689 mm 2 .
The dataset is divided into into 58 images for train and 58 images for test, as done in previous work.
DDSM-BCRP dataset consists of 174 annotated masses, provided by radiologists.
The dataset is divided into into 78 images for train and 5788 images for test, as done in previous work.
SCD dataset The Sunnybrook Cardiac Data (SCD), the MICCAI 2009 Cardiac MR Left Ventricle Segmentation Challenge data, consist of 45 cine-MRI images from a mix of patients and pathologies.
The dataset is split into three groups of 15, resulting in about 260 2D-images each, and report results for the endocardial segmentation.
Tab. 2 and 3 show that our method outperforms all baseline methods on the three medical imaging benchmarks.
Sample results for our method are shown in Fig. [Figure] [Figure] [Table]
[Figure]
[Table]
4. S TREET V IEW I MAGES
Following Ling et al.
(2019), we employ the Cityscapes dataset (Cordts et al., 2016) to evaluate our model in the task of segmenting street images.
The dataset consists of 5000 images, and the experiments employ the train/val/test split of Castrejon et al.
Results are evaluated using the mean IoU metric.
The Cityscapes dataset, unlike the other datasets, contains single objects with multiple contours.
Similarly to Curve-GCN (Ling et al., 2019), we ﬁrst train our model on to segment single contours, given the patch that contains that contour.
Then, after the validation error stops decreasing, we train the ﬁnal network to segment all contours from the patch that contains the entire object.
Note that the network outputs a single output contour for the entire instance.
We follow the same augmentation process as presented for the buildings datasets, using an input resolution of 64 × 64 .
We compare our method with previous work on semantic segmentation, including PSPDeepLab (Chen et al., 2017), and the polygon segmentation methods Polygon-RNN++ (Acuna et al., 2018) and Curve-GCN (Ling et al., 2019).
As can be seen in from Tab. 4, our model outperforms and all other methods in six out of eight categories, and achieves the highest average performance across classes by a sizable margin that is bigger than the differences between the previous contributions (the previous methods achieve average IoU of 71.38–73.30, we achieve 76.35) .
Unlike Curve-Net (Ling et al., 2019), we do not use additional supervision in the form of explicit point location and edge maps.
Sample results can be seen in Fig.
4. M ODEL S ENSITIVITY
To evaluate the sensitivity of our method to the key parameters, we varied the number of nodes in the polygon and the number of iterations.
Both parameters are known to effect active contour models.
Number of Vertices
We experimented with different number of vertices, from simple to complex polygons - [4, 8, 16, 32, 64, 128].
In Fig.
8 - top row, we report the Dice and mIoU on all datasets, including results on DARNet (Cheng et al., 2019) on their evaluation datasets.
As can be seen, segmenting with simple polygons yields lower performance, while as the number of vertices increases the performance quickly saturated at about 32 vertices.
A clear gap in performance is visible between our method and DARNet (Cheng et al., 2019), especially with low number of vertices.
Fig.illustrates that gap on the two buildings datasets.
Number of Iterations
The effect of the iterations number is show to be moderate, although a mean increase is seen over all datasets, saturating at about 3 iterations. [Figure] [Figure] Training Image Resolution
All of our models are trained at the resolution of 64 × 64 pixels . We have experimented with different input resolutions on the Vaihingen dataset. As can be seen in Tab. 5, there is a steep degradation in performance below 64 , which we attribute to the lack of details. When doubling the resolution to 128 × 128 , the performance slightly degrades, however, that model could improve with further training epochs.
Ablation Study In Tab. 6 we show the effect of different loss combinations on our model performance on the Vaihingen benchmark.
The compound loss L is better than its derivatives.
Each the ballooning loss improves performance over not using auxiliary losses at all, while the curvature loss by itself does not.
We note that even without no the auxiliary losses, with a single straightforward loss term, our method outperforms the state of the art.
C ONCLUSIONS
Active contour methods that are based on a global neural network inference hold the promise of improving semantic segmentation by means of an accurate edge placement.
We present a novel method, which could be the most straightforward active contour model imaginable.
The method employs a recent differential renderer, without making any modiﬁcations to it, and simple MSE loss terms.
The elegance of the model does not come at the expense of performance, and it achieves [Table] [Table] state of the art results on a wide variety of benchmarks, where in each benchmark, it outperforms the relevant deep learning baselines, as well as all classical methods.