Fourier Contour Embedding for Arbitrary-Shaped Text Detection
- Publication
- CVPR 2021Conference
- First submitted to arXiv
- arXiv:2104.10442
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{textdetectionfcenet2021,
title = {{Fourier Contour Embedding for Arbitrary-Shaped Text Detection}},
author = {Yiqin Zhu and Jianyong Chen and Lingyu Liang and Zhanghui Kuang and Lianwen Jin and Wayne Zhang},
year = {2021},
eprint = {2104.10442},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2104.10442}
}
You open this paper expecting to learn some text detection techniques.
But you are suddenly hit by Fourier, and before you know it, you are knocked out cold.
Fourier Transform
The mathematician Joseph Fourier introduced this mathematical tool in the early 19th century, and it has since made a huge impact, dominating various fields for over a century.
The core idea of Fourier is quite simple:
- Under suitable regularity or integrability conditions, signals can be represented using sinusoidal components. Here we use a periodic contour and its Fourier series.
Just like breaking down each note in music, the Fourier transform helps us extract the frequency components from a seemingly chaotic time or spatial signal.
Its applications have long surpassed the fields of mathematics and physics, appearing in engineering, medicine, astronomy, and even in modern deep learning techniques.
However, even if we want to "simply" introduce the Fourier Transform, it would still take up too much space. So, we’ve written a separate article to discuss this topic:
If you’re still unsure what the Fourier Transform is, feel free to click and check it out.
Defining the Problem
Text with multiple directional distortions has always been a major challenge for researchers.
Existing methods are mostly based on spatial domain representations, such as pixel masks or contour point sequences, using Cartesian or polar coordinate systems. However, these methods have some drawbacks:
- Mask representations require high computational cost and are highly dependent on large-scale training data.
- Contour point sequence representations have limited modeling ability for highly curved text.
What we need is a concise and generalizable representation of text instances.
Since the problem in the spatial domain is difficult to solve, why not change our approach and look at it from the frequency domain?
And so, Fourier, it’s your time to shine!
Solving the Problem
Fourier Contour Embedding
The original term is Fourier Contour Embedding, abbreviated as FCE.
FCE uses a complex-valued function to represent a closed "text contour":
where is the imaginary unit, and represents the spatial coordinates at contour parameter .
Since is a closed contour, we have .
Through the Inverse Fourier Transformation (IFT), can be expressed as:
where are the complex Fourier coefficients, representing the initial state of frequency .
Each term represents a circular motion of a specific frequency.
- Low frequencies: Responsible for the overall shape of the contour.
- High frequencies: Responsible for the details of the contour.
The experiments use , retaining frequencies from through : 11 complex coefficients, or 22 real values. This compact representation approximates the evaluated contours well.
In practical applications, since the functional form of the text contour is unknown, the function must be discretized into points:
The Fourier coefficients can be computed using the Fourier transform:
where , is the real part, and is the imaginary part.
When , the coefficient is the mean of the sampled boundary points, not in general the area centroid of the enclosed region:
The final Fourier signature vector is:
FCE Sampling Process
Since different datasets have different numbers of contour points (e.g., CTW1500 has 14 points, Total-Text has between 4 and 8 points), the authors standardize the format through resampling, selecting a fixed number of evenly spaced points along the contour (in the experiment, ).
To ensure the stability of the signature vector, the following constraints are applied to the resampling process:
- Starting point: Set as the rightmost intersection of the contour with the horizontal line at the contour's center.
- Sampling direction: Sampling is done in the clockwise direction.
- Uniform speed: The distance between adjacent sampling points is equal.
Model Architecture
Putting aside the complex Fourier problems, the design of this paper is actually very simple and clear.
The anchor-free text detection network based on FCE is named FCENet by the authors.
FCENet uses ResNet50 (with Deformable Convolution DCN) as the backbone, and FPN (Feature Pyramid Network) is employed to capture multi-scale features. The feature maps , , and are responsible for small, medium, and large-scale text, respectively.
The methods used in this part are similar to previous works, so we won't go into details here.
The prediction head consists of two branches:
-
Classification Branch
The upper part of the image above, the Classification Branch, is further divided into two sub-branches:
- Prediction of the text region (Text Region, TR) mask for each pixel.
- Prediction of the text center region (Text Center Region, TCR) mask. Its score is multiplied pixel by pixel with the TR score to suppress lower-quality boundary predictions.
-
Regression Branch
This is the core objective of this paper: predicting a Fourier signature vector for each text-region pixel. Pixels of one instance share the same coefficients except , which shifts with the pixel chosen as the coordinate origin.
The calculation of the Fourier signature vector, mentioned in the previous section, is intended to provide the training targets for this branch.
The predicted vectors reconstruct candidate contours through the Inverse Fourier Transformation (IFT); NMS then selects the final detections, as shown below:
Loss Function
The total loss is:
where .
The classification loss and regression loss are as follows:
-
Classification Loss
Here and are cross-entropy losses for the text region and center region. The paper applies OHEM with a 3:1 negative-to-positive sample ratio to ; it does not state that this sampling rule also applies to .
-
Regression Loss
To directly optimize the detection quality in the spatial domain, rather than the distance between Fourier signature vectors, the loss is designed as:
Where:
- is the smooth loss.
- is the Inverse Fourier Transform.
- is the set of pixels in the text region.
- and are the true and predicted Fourier signature vectors, respectively.
- is the weight, with for pixels in the center region, and otherwise.
- The number of sampling points is , to avoid overfitting.
Training Datasets
-
1. CTW1500
- Contains Chinese and English text, with text-line level annotations.
- Dataset size: 1000 training images, 500 test images.
-
2. Total-Text
- Contains multi-scene data, including background interference similar to text and low-contrast text.
- Annotations are polygon-level at the word level.
- Dataset size: 1255 training images, 300 test images.
-
3. ICDAR2015
- A dataset designed for multi-directional street scene text, with word-level annotations represented by four vertices.
- Dataset size: 1000 training images, 500 test images.
Discussion
FCE Evaluation
Increasing provides more Fourier components and can improve approximation. The convergence statement depends on the contour’s regularity and the error measure.
According to the results shown in the figure above, a small is sufficient to achieve a satisfactory fit for most arbitrary-shaped text contours, which demonstrates the powerful representational ability of FCE.
When comparing FCE with the latest method for arbitrary-shaped text detection, TextRay, the results are as follows:
For highly curved text, TextRay fails to accurately fit the real contours, showing its limitations in modeling highly curved text. In contrast, FCE shows a high degree of accuracy when fitting such text contours.
In these contour-fitting examples, FCE uses 22 real dimensions, while TextRay uses 44. The FCE contours shown for highly curved text follow the ground truth more closely.
Ablation Experiments
To verify the effectiveness of each component of FCENet, the authors conducted ablation experiments on the CTW1500 and Total-Text datasets. The conclusions are as follows:
- Text Center Region (TCR) Loss: Adding TCR alone to the no-TCR/no-regression baseline raises F-measure by 1.5 percentage points on CTW1500 and 0.4 points on Total-Text.
- Regression Loss: Adding contour regression to the TCR setting raises F-measure by another 6.9 and 9.3 points, respectively. With both losses, the final F-measures are 85.5% and 85.8%.
Generalization Ability
To verify the generalization ability of FCE, the authors conducted experiments on the CTW1500 dataset by reducing the training data. They reduced the training data to 50% and 25% of the original size, and compared the results with other methods (such as DRRG, TextRay, ABCNet).
The table reports FCENet† without DCN. With 50% and 25% of CTW1500 training data, its precision is 84.9% and 81.9%, and its F-measure is 80.3% and 78.7%. Those values exceed the three methods listed under the same data fractions, supporting its performance in these limited-data CTW1500 settings.
Comparison with Other Methods
- Ext: Represents the use of additional training data.
- †: Represents the simplified version of FCENet† without DCN.
FCENet was compared with other recent methods on the CTW1500 and Total-Text datasets, and the results are as follows:
- Precision (P) and F-measure (F): FCENet has the highest listed values for both on CTW1500. On Total-Text, its 89.3% precision ties the extra-data PAN row, and its 85.8% F-measure is highest.
- Recall (R): Achieved competitive results.
On ICDAR2015, FCENet uses no extra training data and reaches 86.2% F-measure, below several rows in the table.
FCENet's postprocessing consists of IFT and NMS. Even with ResNet50 without DCN, FCENet† reaches 83.1%, 83.4%, and 84.6% F-measure on CTW1500, Total-Text, and ICDAR2015. ABCNet also uses a non-DCN ResNet50 in this table, although other training conditions must be considered separately.
High-Curvature Text
Finally, the authors selected 106 highly curved text samples from CTW1500 to test the model on difficult contours.
The four columns show TextRay, ABCNet, FCENet, and ground-truth contours, in that order. On this subset, Table 4 reports 79.2% F-measure for FCENet, 5.2 points above TextRay's 74.0% and 6.6 points above ABCNet's 72.6%.
Conclusion
The elegance of Fourier is beyond question.
The Fourier Contour Embedding method proposed in this paper can accurately represent text contours of any shape, especially excelling in fitting high-curvature text. FCENet, by predicting Fourier signature vectors and performing inverse transformations to reconstruct the text contour, uses a comparatively simple postprocessing pipeline of inverse reconstruction and NMS, achieving a balance between accuracy and practicality, making it particularly suitable for detecting complex contours and curved text.
The Fourier method is not only a mathematical tool but also a powerful means of solving practical problems. Through FCE and FCENet, the authors provide an efficient and practical solution for arbitrary-shaped text detection and open up possibilities for future text shape modeling.