<figure><img src="image_1.png" /></figure>

HAL
open science

# A comparative study of Fourier transform and CycleGAN as domain adaptation techniques for weed segmentation

Riccardo Bertoglio, Alessio Mazzucchelli, Nico Catalano, Matteo Matteucci

► To cite this version:

Riccardo Bertoglio, Alessio Mazzucchelli, Nico Catalano, Matteo Matteucci. A comparative study of Fourier transform and CycleGAN as domain adaptation techniques for weed segmentation. Smart Agricultural Technology, 2023, 4, pp.100188. 10.1016/j.atech.2023.100188. hal-05106193

HAL Id: hal-05106193

https://hal.science/hal-05106193v1

Submitted on 10 Jun 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
<figure><img src="image_3.png" /></figure>

<figure><img src="image_4.png" /></figure>

# A comparative study of Fourier transform and CycleGAN as domain adaptation techniques for weed segmentation

Riccardo Bertoglio *, Alessio Mazzucchelli, Nico Catalano, Matteo Matteucci

Department of Electronics, Information and Bioengineering, Politecnico di Milano, Via Ponzio 34/5, Milan, 20133, Italy

## ARTICLE INFO

Editor: Spyros Fountas

Keywords:

Weed identification
Semantic segmentation
Domain adaptation
Fourier transform
Generative adversarial networks

## ABSTRACT

Automatic weed identification is becoming increasingly important in the Precision Agriculture field as a fundamental capability for targeted spraying or mechanical weed destruction. Targeted weed elimination reduces herbicides' use and thus lowers the environmental impact of treatments. Convolutional Neural Networks are one of the most successful techniques to automatically detect weeds on RGB images. Such models require a high amount of labeled data to obtain satisfying detection performance. The agricultural context presents a high degree of variability, and it is thus unfeasible to expect a representative dataset for each specific condition that can appear in the fields. Domain Adaptation techniques are exploited to maintain high detection performance in different field conditions, lowering the need for labeled data. This study presents a comparison of the two main style transfer techniques for performing domain adaptation, that is, the Fourier Transform and the CycleGAN architecture. We used these techniques to reduce the domain gap in two use cases: one with images collected by different robots with different cameras and another with images collected by the same platform in different years. We show how, in the first case, the CycleGAN architecture attains satisfying performance and beats the simpler Fourier Transform. Instead, in the second case, all the tested DA techniques struggle to reach baseline performance. We also show how introducing a loss based on phase discrepancy in the CycleGAN architecture stabilizes the training and improves the performance. Moreover, we release a new dataset of labeled agricultural images and the code of our experiments for the reproducibility of the results and comparison with future works.

## 1. Introduction

Precision Agriculture is a farming management concept based on observing, measuring, and responding to inter and intra-field variability in crops. PA research aims to define decision support systems for whole-farm management, optimizing returns on inputs and thus preserving resources [1]. A typical agricultural task is weed destruction, which is usually tackled by spraying herbicides uniformly all over the field. The practice of uniform spraying poses environmental and economic concerns since part of the products are wasted because they are not targeted at weeds. The waste of herbicide products can contaminate the soil and decreases the crops' profits.

To reduce such waste, we need systems capable of targeted destruction to adapt the traditional weed removal practices to the concept of PA [2]. One option to implement such a targeted weed removal is to use smart implements capable of precise herbicide spraying limited to the weeds' area [3]. Alternatively, smart implements could perform mechanical destruction, thus eliminating the need for herbicides. Such

smart implements need identification and distinction capabilities of weeds and crop plants, and RGB cameras can be used to capture weeds and crop plants [4]. Machine Learning (ML) algorithms then analyze images to detect the different plants and categorize them into crop or weed classes. The most successful ML technique in recent years is the use of Convolutional Neural Networks (CNN) [5-7], which, thanks to their ability to extract features automatically, can classify images without any domain knowledge of the task they are dealing with.

However, the performance of a classifier trained on a specific set of images (i.e., the source domain) decreases when deployed in new environments or under changing conditions (i.e., the target domain). Agricultural environments are intrinsically variable in time and spatial dimensions. Each plant is different from the others, and its appearance changes over time. Thus, the domain difference in the agricultural context is due to different weed types, growth stages of plants, soil conditions, and illumination. Maintaining good performance in such a variable environment requires broad datasets containing examples of all the possible conditions encountered in the field. Since the labeling

<footnote>* Corresponding author.
E-mail address: riccardo.bertoglio@polimi.it (R. Bertoglio).</footnote>
process is costly both in terms of time and money, it is not feasible to expect enough labeled data for each new field condition that needs to be classified. Thus, Domain Adaptation (DA) techniques have been proposed to reduce the need for labeled data.

DA is a concept under which we aim to learn a model on a source domain and attain good performance on a different (but related) target domain [8]. DA techniques are classified along different dimensions [9]. In this study, we address unsupervised DA, meaning that the target domain labels are not available. Indeed, to see weed segmentation models deployed in the real world, it is necessary to remove the dependence on labeled images for each new situation that can appear in the fields. The image labeling process takes too much time, while agricultural tasks must be performed in a timely manner. It is not feasible to postpone an agricultural task for weeks because the actual field conditions were not captured in the original labeled dataset. Beyond the unsupervised DA setting, our studied scenario is characterized by being a closed set task because all the possible classes (crop, weed, and background) appear both in the source and target domains. Finally, in our study, we address input-level DA [9] techniques to minimize the domain gap by aligning the visual appearance of source and target domain images. The downside of some of these input-level techniques is that they do not preserve semantic consistency when transferring the style. Indeed, pixels of a certain class can be mapped into a different class in the style-transformed images. This problem is typical of adversarial-based approaches, which require constraints to maintain semantic consistency.

Few pixel-level DA approaches for weed segmentation have been tested and presented in the literature. A method based on the CycleGAN architecture [10] has been proposed in [11]. The CycleGAN architecture is built on a pair of generative adversarial models, concurrently performing image translation between domains in both the source-to-target and target-to-source directions. The two adversarial modules are further tied by a cycle-consistency constraint, which is essential to preserve the geometrical properties of the input scene but provides no guarantees about the semantic consistency of the translations. In [11], the authors forced cross-domain image translations to preserve the semantic content by introducing a measure of semantic discrepancy between the original image and its translated counterpart. This measure is then minimized as an additional loss function in the learning process of the translation networks.

An alternative approach to perform style transfer and DA is via the use of the Fourier Transform [12]. When the Fourier transform is applied to an image, it is possible to extract its phase and amplitude components. The phase component carries the semantic information of the image, while the amplitude holds the style. Swapping the amplitude of a source image with the amplitude of a target image results in an image with the source semantics and the target style. In the weed segmentation field, the Fourier Transform has been tested in [13]. The authors showed how performing the style transfer through the Fourier Transform leads to higher performance compared to the baseline in the crop-weed segmentation task. They also demonstrated that preprocessinging the images with the Contrast Limited Adaptive Histogram Equalization (CLAHE) technique [14] further improves the performance.

To the best of our knowledge, no study compares the current literature DA techniques for weed segmentation. This study aims to test and compare the Fourier Transform and CycleGAN techniques on the same dataset. We tested the original CycleGAN architecture with two extensions to force semantic consistency: the extension proposed by [11] by introducing IoU losses, and that proposed by [15], in which they minimize the phase difference between real and transformed images. Finally, we release a new labeled dataset of crop-weed images collected in bean and maize fields with four species of weeds. The dataset comprises eight sets of images collected by four robots with different RGB cameras and field of views in two different years, 2019 and 2021. We also release the code of our experiments to reproduce our results and for comparison with future works. Download the dataset and code at https://doi.org/10.17632/x8brgg2j28.2.

## 2. Domain adaptation techniques

In this study, we compare the main literature pixel-level unsupervised DA techniques for weed segmentation by testing them on the same dataset of agricultural images. The analyzed techniques are the Fourier Transform and the CycleGAN architecture. We test two modifications of the original CycleGAN architecture by introducing loss components to maintain semantic consistency in the transformed images. The results obtained from these techniques are compared to a baseline and an upper bound. In the following, we explain how we implemented the different tested techniques.

### 2.1. Baseline and upper bound

To compare the DA techniques with lower (baseline) and upper bounds, we designed a model based on a U-net segmentation network [16]. We implemented the encoder part of the network with a VGG16 [17] pre-trained on Imagenet [18] used as a backbone. In Fig. 1 we show a graphical representation of the segmentation network. We designed the network's output with a 1x1 convolutional softmax activation layer that predicts the probability of a pixel location to be of the class crop, weed, and background. We then produced the baseline results by training this model on the source domain and predicting on the target domain. Instead, we produced the upper bound results by directly training the model on the target domain to predict on the same domain.

We trained the baseline model using a loss function based on the softIoU computed as [19]:

$$ \text{softIoU} = \frac{1}{|C|} \sum_{c} \frac{\sum_{i} p_{ic} \cdot p_{ic}^{*}}{\sum_{i} p_{ic} + p_{ic}^{*} - p_{ic} \cdot p_{ic}^{*}} $$

where C is the set of classes, $p_{ic}$ is the prediction probability of a pixel i to be of class c, $p_{ic}^{*}$ is the ground truth distribution, 1 if the pixel i belongs to class c, 0 otherwise.

Similarly to the learning scheduler used in [11], we set the initial learning rate of 0.0001 and we linearly decreased it towards zero, multiplying it by 0.1 every time the IoU loss did not improve after 4 epochs. We used the Adam optimizer [20] and 256x256 padded tiles (total padded size of 320x320) from the original images. We augmented the training set by performing horizontal and vertical flips with a probability of 0.5 in both directions. During testing, we did not use any padding.

### 2.2. Fourier transform

Starting from the well-known concept that an image amplitude contains information about its style while the phase carries its semantics, the authors of [12] proposed an unsupervised DA method based on amplitude swapping. Given an image in the source dataset and one in the target dataset, the authors propose to swap the low-frequency component of the amplitudes of their Fourier Transforms.

More formally, given $\beta \in [0, 1]$ we define a mask $M_{\beta}$ where the coordinate system origin (0,0) is in the center of the image as:

$$ M_{\beta}(h, w) = 1_{(h,w) \in [-\beta H : \beta H, -\beta W : \beta W]} $$

We use the $M_{\beta}$ mask to select the low-frequency part of the amplitude. Then, called $\mathcal{F}$ the Fourier Transform of an image and $\mathcal{F}^{-1}$ the inverse transform, sampled an image from the target domain $x^s \in D^s$, and an image from the target domain $x^l \in D^l$, we can perform the DA via amplitude swap by:

$$ x^{s \to l} = \mathcal{F}^{-1} \left( [M_{\beta} \circ \mathcal{F}^A(x^l) + (1 - M_{\beta}) \circ \mathcal{F}^A(x^s)] \circ \mathcal{F}^P(x^s) \right) $$

As noted by [12], setting $\beta$ is a trade-off between transformation and introducing noise. In our experiments, we reached a good compromise setting $\beta = 0.1$.

To evaluate the Fourier Transform technique, we transformed the source images in the target style, and then we trained a U-Net model with the source labels. Then, we used this model to predict the unla beled target domain images. For each source image, we randomly chose
<figure><img src="image_5.png" /><figcaption>Fig. 1. Our U-net architecture for semantic segmentation.</figcaption></figure>

a target image to perform the amplitude swap. By randomly choosing a different target image for each source image, we are sure to represent the distribution of target styles in the source-transformed images.

## 2.3. CycleGAN

As pointed out in [11], the original CycleGAN architecture [10] cannot guarantee the preservation of the semantics in the transformed images. To enforce semantic consistency, the authors of [11] proposed constraining the labels of an image to be equal to the labels of its transformation. Thus, in the original CycleGAN implementation, they added two additional semantic losses involving both the source domain and the target domain. These losses force the source Fully Convolutional Network (FCN) to predict labels to be as similar as possible to the ground truth. At the same time, they force the target FCN to predict segmentations to be as close as possible to the prediction made by the source FCN on the translated images. The complete CycleGAN architecture is depicted in Fig. 2. In the figure, we highlighted in purple the components of the $\mathcal{L}_{semantic}$ loss as proposed in [11] and composed as:

$$ \mathcal{L}_{semantic} = \mathcal{L}_{softIoU}(\bar{s}_{G(x)}, s_{X}) + \mathcal{L}_{softIoU}(\bar{s}_{F(G(x))}, s_{X}) + \mathcal{L}_{softIoU}(\bar{s}_{Y}, \bar{s}_{F(y)}) + \mathcal{L}_{softIoU}(\bar{s}_{G(F(y))}, \bar{s}_{F(y)}) $$

where $\mathcal{L}_{softIoU}$ is a softIoU-based loss, $s$ identifies the ground truth labels, and $\bar{s}$ the predicted labels. Moreover, $x \in X$ is an image from the source domain, and $y \in Y$ is an image from the target domain. Finally, $G$ is the generator responsible for the source-to-target translation, and $F$ is the generator for target-to-source translation.

We then added a constraint on the image phase to further improve semantic preservation. As explained earlier, an image's phase component contains information about its semantics, while the amplitude carries information about its style. Consequently, we penalized the phase discrepancy between real and transformed images through a loss function proposed in [15]:

$$ \mathcal{L}_{phase}(T, x) = - \sum_{j} \frac{\langle F(x)_j, F(T(x))_j \rangle}{||F(x)_j||_2 \cdot ||F(T(x))_j||_2} $$

where $\langle \cdot, \cdot \rangle$ is the dot-product, $|| \cdot ||_2$ is the $L_2$ norm, $F$ the Fourier Transform and $T$ the transformation function of the generator being trained. We implemented the Fourier Transform $F$ via the Fast Fourier Transform algorithm [21]. In Fig. 2 we depicted the new loss with orange rectangles and arrows. We applied this loss to both source-transformed and target-transformed images to enforce semantic consistency in both directions. At the implementation level, we summed the phase loss to

the total loss of the CycleGAN architecture. Thus, the total loss adds up to:

$$ \mathcal{L}_{total} = \mathcal{L}_{GAN} + \mathcal{L}_{cycle} + \mathcal{L}_{semantic} + (\mathcal{L}_{phase}(G(x), x) + \mathcal{L}_{phase}(F(y), y))/2 $$

Where $\mathcal{L}_{GAN}$ is the adversarial loss as specified in [22], and $\mathcal{L}_{cycle}$ is used to enforce cycle consistency as proposed in [10]. We divided the sum of the phase losses by 2 to uniform its magnitude to that of the other losses.

We built the CycleGAN architecture as proposed in [11] but with U-net generators as represented in Fig. 1. The training has been performed with a learning rate of 0.0002 for the first 100 epochs, halving it after the 100th epoch and then halving it again every 20 epochs. To perform the predictions on the target domain, we then use the FCN $f_y$ network trained in the CycleGAN model.

## 3. Dataset and experiments

The images we used in our experiments come from the ROSE Challenge [23], a benchmarking competition of agricultural robots focused on autonomous weed destruction. The ROSE Challenge has been organized by the National Laboratory of Metrology and Testing (LNE) and the National Research Institute for Agriculture, Food, and the Environment (INRAE). Four teams participated in the ROSE field campaigns with different robots and camera systems. The teams' names are BIPBIP, PEAD, ROSEAU, and WeedElec. The images used in our experiments were collected in the years 2019 and 2021 in an experimental field at the INRAE research center located in Montoldre, France. The teams scanned maize (Zea mays) and bean (Phaseolus vulgaris) plants with four kinds of weeds (Lolium perenne, Sinapis arvensis, Chenopodium album, Matricaria chamomilla) under natural daylight conditions. The dataset is composed of RGB images (with different resolutions) and semantic segmentation masks to distinguish the crop, weed, and background classes. There are 1000 labeled images in total (125 per team and crop type) per year.

In our experiments, we performed two kinds of style transfer. In the first set of experiments, we used images collected by different robots with different cameras but of the same field and in the same period (May 2019). Specifically, we used the images of the teams BIPBIP and WeedElec, with both maize and bean crops, being the most similar in terms of shooting conditions. In the second set of experiments, we used images collected by the same robot and camera but in different years and periods (May 2019 and September 2021). The images were collected by the BIPBIP team, and plants were at different growth stages
<figure><img src="image_6.png" /><figcaption>**Fig. 2.** The model proposed in [11] consists of two generators responsible for translate source-to-target (generator G) and from target-to-source (generator F). The model also includes two segmentation networks: $f_X$ to segment in the source domain, $f_Y$ to segment in the target domain. The $L_{softIoU}$ loss developed by [11] (purple arrows) enforces semantic consistency using the mask predicted by the segmentation modules and the ground truth. The other additional loss (orange arrows) consists of a phase loss $L_{phase}$ that encourages the generators to minimize the phase discrepancy between original and translated images. In the image, $s$ identifies the ground truth labels, and $\bar{s}$ the predicted labels.</figcaption></figure>

<caption>**Table 1**</caption>

Mean IoU (crop, weed, and background classes) results for the four combinations of the BIPBIP and WeedElec teams' images.

<table><caption>**Table 2**</caption><thead><tr><th>Crop</th><th>Source Domain</th><th>Target Domain</th><th>Baseline</th><th>Fourier Transform</th><th>CGAN LSemantic</th><th>CGAN Lphase</th><th>Upper Bound</th></tr></thead><tbody><tr><td rowspan="2">Bean</td><td>BIPBIP</td><td>WeedElec</td><td>0.741</td><td>0.787</td><td><strong>0.827</strong></td><td>0.808</td><td>0.870</td></tr><tr><td>WeedElec</td><td>BIPBIP</td><td>0.726</td><td>0.835</td><td>0.827</td><td><strong>0.844</strong></td><td>0.847</td></tr><tr><td rowspan="2">Maize</td><td>BIPBIP</td><td>WeedElec</td><td><strong>0.843</strong></td><td>0.838</td><td>0.587</td><td>0.645</td><td>0.893</td></tr><tr><td>WeedElec</td><td>BIPBIP</td><td>0.614</td><td>0.799</td><td>0.770</td><td><strong>0.841</strong></td><td>0.883</td></tr></tbody></table>

Mean IoU (crop, weed, and background classes) results for the four combinations of the 2019 and 2021 BIPBIP images.

<table><thead><tr><th>Crop</th><th>Source year</th><th>Target year</th><th>Baseline</th><th>Fourier Transform</th><th>CGAN LSemantic</th><th>CGAN Lphase</th><th>Upper Bound</th></tr></thead><tbody><tr><td rowspan="2">Bean</td><td>2019</td><td>2021</td><td>0.726</td><td><strong>0.738</strong></td><td>0.539</td><td>0.539</td><td>0.805</td></tr><tr><td>2021</td><td>2019</td><td><strong>0.807</strong></td><td>0.787</td><td>0.426</td><td>0.628</td><td>0.847</td></tr><tr><td rowspan="2">Maize</td><td>2019</td><td>2021</td><td><strong>0.766</strong></td><td>0.741</td><td>0.239</td><td>0.276</td><td>0.808</td></tr><tr><td>2021</td><td>2019</td><td><strong>0.854</strong></td><td>0.837</td><td>0.705</td><td>0.460</td><td>0.883</td></tr></tbody></table>

in the two years. Thus, we came up with four combinations of source and target domains and crops for each set of experiments. The dataset [24] and code of the experiments are available at this URL https://doi.org/10.17632/x8brgg2j28.2.

In both sets of experiments, we compared three unsupervised DA approaches against a baseline and an upper bound. We summarized the results in Tables 1 and 2. Table 1 shows the comparison results for the two image sets of BIPBIP and WeedElec teams collected in 2019, while Table 2 shows the comparison results for the image sets of the BIPBIP team collected in the years 2019 and 2021. For each combination of crop-source-target, we tested the Fourier Transform technique, the CycleGAN architecture as proposed in [11] (named “CGAN LSemantic”), and the same CycleGAN architecture but with the additional phase loss as proposed in [15] (named “CGAN Lphase”). We measured the algorithms’ segmentation performance with the IoU over the classes crop, weed, and background.

The first set of experiments was characterized by a domain shift caused by different camera models and acquisition parameters. In this setting, the generative models outperformed the baseline and the Fourier Transform in three out of four comparisons. The baseline outperformed all the other methods in the experiment with BIPBIP as the source domain, WeedElec as the target domain, and the maize crop.

We hypothesize that a higher proportion of background pixels gave the FCN $f_Y$ a poor crop-weed discrimination capability. Indeed, the WeedElec maize images were taken at a larger distance from the ground than the BIPBIP images, which turned into a higher portion of the image being just soil (that is, background class). Also, since the CycleGAN models are trained with image tiles, a significant portion of them consisted of just soil. In Fig. 3 we show the transformation of the same source image into the target domain with the three tested methods. We can observe that in the case of the BIPBIP to WeedElec (bean crop) transformation, the target image consists of only ground. The CGAN LSemantic method completely removed the plant from the source image, while the CGAN Lphase retained the crop plant.

The Fourier Transform method achieved better results than the baseline in three comparisons and comparable performance in one. Finally, the introduction of the phase loss in the CycleGAN architecture (CGAN Lphase) led to overperforming the CGAN Lsemantic approach in three comparisons. In Fig. 4, for each of the four comparisons, we show the predictions of the three tested methods, plus the baseline and the ground truth. In general, we noticed that the CycleGAN models found more weeds than those in the ground truth. By inspecting the images closely, we verified that the CycleGAN models produced a better prediction.
<figure><img src="image_7.png" /><figcaption>Fig. 3. Comparison of the results of the DA techniques used. In the first two columns, we display the source and target images taken by the two teams BIPBIP and WeedElec. We display the results of the transformation of the source images into the target style in the remaining three columns. The third column shows the transformation via the Fourier Transform technique, then the transformation via the CGAN LSemantic method, and finally, the CGAN LPhase method.</figcaption></figure>

<figure><img src="image_8.png" /><figcaption>Fig. 4. Comparison of segmentation predictions performed with four models. In the first column is displayed the target image being segmented. The baseline column displays the segmentation performed by training the model with source labels. In the first column, we show the Fourier Transform predictions from a model trained on the translated dataset. The CGAN LSemantic and CGAN LPhase columns show the segmentation predictions produced with the CycleGAN models. In the last column, we show the ground truth.</figcaption></figure>

tion than the ground truth in many cases. Indeed, we noticed that the human annotators had missed the smallest and merely visible weeds.

The second set of experiments was characterized by a domain shift due to a different growth stage of the plants. In this setting, the generative models presented performance under the baseline, as shown in Table 2. The style-transfer methods exploited in this study were thus helpful in the case of a domain gap caused by different camera models, but they struggled when the domain gap was because of plants with different shapes. In this setting, features-level DA methods could perform better than pixel-level ones. Also, the Fourier Transform did not improve the results compared to the baseline but in one case, although with a slight improvement.

In Fig. 5, we show the transformation of the same source image into the target domain with the three tested methods. We notice that the

Fourier transform produced some visible artifacts. Moreover, even the CycleGAN transformed images present alterations which lead to low performance. Fig. 6 compares the mask predictions of the three tested DA methods. The CycleGAN architectures produced many wrongly predicted pixels.

In the Appendix, we reported tables with the experiment results specifying the IoU of the three classes (background, crop, weed) (Tables 3–7). Since the images are heavily unbalanced toward soil pixels, the background class showed higher performance, followed by the crop and weed classes.

Finally, in Fig. 7 and 8, we show the plots of the loss and mean IoU, respectively, for each of the four comparisons in the first set of experiments, that is, with the BIPBIP and WeedElec 2019 images
<figure><img src="image_9.png" /><figcaption>**Fig. 7.** Comparison plots of the losses for the training of the four experiments. CGAN L is the loss as proposed by [11], while CGAN L\_phase is the loss that includes the additional phase discrepancy term.</figcaption></figure>

<figure><img src="image_10.png" /><figcaption>**Fig. 8.** Comparison plots of meanIoU for the model proposed by [11] (CGAN L\_semantic) and the same model with the addition of the phase loss (CGAN L\_phase). The four plots represent the accuracy over the four experiments.</figcaption></figure>

how using an additional loss function based on phase discrepancy further improved the performance and stabilized the training. One of the four combinations of experiments presented DA results worse than the baseline. Indeed, different class proportions of the two domains lead to worse performance. In this case, we suggest using a weighted IoU loss to weigh more the minority classes. The second domain gap was more challenging, and none of the DA techniques could consistently beat the baseline. Both the Fourier Transform and CycleGAN models introduced artifacts in the transformed images. Other models (like features-level methods) should be tested to overcome this problem. Together with this study, we released the entire dataset and code for the reproduction

of the results (including the implementation of literature techniques for which no code was available) and comparison with future works.

## Data availability

The data and code used in the experiments can be downloaded here https://doi.org/10.17632/x8brgg2j28.2.

## Acknowledgements

We thank the ROSE challenge and the METRICS project for providing us the data. This work has been partially funded by the H2020 METRICS project under grant agreement No. 871252.
# Appendix A

<caption>**Table 3**</caption>

IoU results of the baseline. The segmentation model is trained on the source domain and tested on the target without any form of DA.

<table><caption>**Table 4**</caption><thead><tr><th rowspan="2">Crop</th><th rowspan="2">Source<br>Domain</th><th rowspan="2">Target<br>Domain</th><th colspan="4">Baseline</th></tr><tr><th>bgIoU</th><th>cropIoU</th><th>weedIoU</th><th>meanIoU</th></tr></thead><tbody><tr><td rowspan="4">Maize</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.987</td><td>0.835</td><td>0.708</td><td>0.843</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.861</td><td>0.425</td><td>0.557</td><td>0.614</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.912</td><td>0.836</td><td>0.549</td><td>0.766</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.976</td><td>0.845</td><td>0.741</td><td>0.854</td></tr><tr><td rowspan="4">Bean</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.976</td><td>0.697</td><td>0.551</td><td>0.741</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.944</td><td>0.724</td><td>0.511</td><td>0.726</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.939</td><td>0.781</td><td>0.456</td><td>0.726</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.980</td><td>0.802</td><td>0.640</td><td>0.807</td></tr></tbody></table>

IoU results of the Fourier Transform DA. The segmentation model is trained on the source-transformed images and tested on the target domain.

<table><caption>**Table 5**</caption><thead><tr><th rowspan="2">Crop</th><th rowspan="2">Source<br>Domain</th><th rowspan="2">Target<br>Domain</th><th colspan="4">Fourier Transform</th></tr><tr><th>bgIoU</th><th>cropIoU</th><th>weedIoU</th><th>meanIoU</th></tr></thead><tbody><tr><td rowspan="4">Maize</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.986</td><td>0.839</td><td>0.690</td><td>0.838</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.963</td><td>0.740</td><td>0.693</td><td>0.799</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.912</td><td>0.834</td><td>0.477</td><td>0.741</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.971</td><td>0.805</td><td>0.735</td><td>0.837</td></tr><tr><td rowspan="4">Bean</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.974</td><td>0.792</td><td>0.597</td><td>0.787</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.979</td><td>0.822</td><td>0.704</td><td>0.835</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.935</td><td>0.794</td><td>0.484</td><td>0.738</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.978</td><td>0.772</td><td>0.612</td><td>0.787</td></tr></tbody></table>

IoU results of the CGAN LSemantic DA. The segmentation model is trained on the source-transformed images and tested on the target domain.

<table><caption>**Table 6**</caption><thead><tr><th rowspan="2">Crop</th><th rowspan="2">Source<br>Domain</th><th rowspan="2">Target<br>Domain</th><th colspan="4">CGAN LSemantic</th></tr><tr><th>bgIoU</th><th>cropIoU</th><th>weedIoU</th><th>meanIoU</th></tr></thead><tbody><tr><td rowspan="4">Maize</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.981</td><td>0.529</td><td>0.252</td><td>0.587</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.960</td><td>0.732</td><td>0.619</td><td>0.770</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.672</td><td>0.032</td><td>0.011</td><td>0.239</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.966</td><td>0.665</td><td>0.484</td><td>0.705</td></tr><tr><td rowspan="4">Bean</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.976</td><td>0.826</td><td>0.679</td><td>0.827</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.980</td><td>0.822</td><td>0.679</td><td>0.827</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.829</td><td>0.443</td><td>0.347</td><td>0.540</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.877</td><td>0.353</td><td>0.048</td><td>0.426</td></tr></tbody></table>

IoU results of the CGAN LPhase DA. The segmentation model is trained on the source-transformed images and tested on the target domain.

<table><caption>**Table 7**</caption><thead><tr><th rowspan="2">Crop</th><th rowspan="2">Source<br>Domain</th><th rowspan="2">Target<br>Domain</th><th colspan="4">CGAN LPhase</th></tr><tr><th>bgIoU</th><th>cropIoU</th><th>weedIoU</th><th>meanIoU</th></tr></thead><tbody><tr><td rowspan="4">Maize</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.946</td><td>0.487</td><td>0.502</td><td>0.645</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.973</td><td>0.829</td><td>0.723</td><td>0.841</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.683</td><td>0.145</td><td>0.001</td><td>0.276</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.827</td><td>0.340</td><td>0.211</td><td>0.460</td></tr><tr><td rowspan="4">Bean</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.975</td><td>0.811</td><td>0.637</td><td>0.808</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.980</td><td>0.839</td><td>0.714</td><td>0.844</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.855</td><td>0.834</td><td>0.277</td><td>0.539</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.923</td><td>0.549</td><td>0.413</td><td>0.628</td></tr></tbody></table>

IoU results of the upper bound. The segmentation model is trained and tested on the target domain.

<table><thead><tr><th rowspan="2">Crop</th><th rowspan="2">Source<br>Domain</th><th rowspan="2">Target<br>Domain</th><th colspan="4">Upper Bound</th></tr><tr><th>bgIoU</th><th>cropIoU</th><th>weedIoU</th><th>meanIoU</th></tr></thead><tbody><tr><td rowspan="4">Maize</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.993</td><td>0.892</td><td>0.794</td><td>0.893</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.979</td><td>0.880</td><td>0.789</td><td>0.883</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.920</td><td>0.864</td><td>0.641</td><td>0.809</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.979</td><td>0.880</td><td>0.789</td><td>0.883</td></tr><tr><td rowspan="4">Bean</td><td>BIPBIP 2019</td><td>WeedElec 2019</td><td>0.981</td><td>0.970</td><td>0.759</td><td>0.870</td></tr><tr><td>WeedElec 2019</td><td>BIPBIP 2019</td><td>0.984</td><td>0.862</td><td>0.697</td><td>0.847</td></tr><tr><td>BIPBIP 2019</td><td>BIPBIP 2021</td><td>0.955</td><td>0.869</td><td>0.592</td><td>0.805</td></tr><tr><td>BIPBIP 2021</td><td>BIPBIP 2019</td><td>0.984</td><td>0.862</td><td>0.697</td><td>0.847</td></tr></tbody></table>
## References

[1] R. Bertoglio, C. Corbo, F.M. Renga, M. Matteucci, The digital agricultural revolution: a bibliometric analysis literature review, IEEE Access (2021).

[2] K.G. Liakos, P. Busato, D. Moshou, S. Pearson, D. Bochtis, Machine learning in agriculture: a review, Sensors 18 (8) (2018) 2674.

[3] B. Liu, R. Bruch, Weed detection for selective spraying: a review, Curr. Robot. Rep. 1 (1) (2020) 19-26.

[4] X. Wu, S. Aravecchia, P. Lottes, C. Stachniss, C. Pradalier, Robotic weed control using automated weed and crop classification, J. Field Robot. 37 (2) (2020) 322-340.

[5] A.M. Hasan, F. Sohel, D. Diepeveen, H. Laga, M.G. Jones, A survey of deep learning techniques for weed detection from images, Comput. Electron. Agric. 184 (2021) 106067.

[6] A. Milioto, P. Lottes, C. Stachniss, Real-time semantic segmentation of crop and weed for precision agriculture robots leveraging background knowledge in CNNs, in: 2018 IEEE International Conference on Robotics and Automation (ICRA), IEEE, 2018, pp. 2229-2235.

[7] P. Lottes, J. Behley, A. Milioto, C. Stachniss, Fully convolutional networks with sequential information for robust crop and weed detection in precision farming, IEEE Robot. Autom. Lett. 3 (4) (2018) 2870-2877.

[8] G. Csurka, Domain adaptation for visual applications: a comprehensive survey, arXiv preprint, arXiv:1702.05374, 2017.

[9] M. Toldo, A. Maracani, U. Michieli, P. Zanuttigh, Unsupervised domain adaptation in semantic segmentation: a review, Technologies 8 (2) (2020).

[10] J.-Y. Zhu, T. Park, P. Isola, A.A. Efros, Unpaired image-to-image translation using cycle-consistent adversarial networks, in: Proceedings of the IEEE International Conference on Computer Vision, 2017, pp. 2223-2232.

[11] D. Gogoll, P. Lottes, J. Weyler, N. Petrinic, C. Stachniss, Unsupervised domain adaptation for transferring plant classification systems to new field environments, crops, and robots, in: 2020 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), IEEE, 2020, pp. 2636-2642.

[12] Y. Yang, S. Soatto, FDA: Fourier domain adaptation for semantic segmentation, in: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020, pp. 4085-4095.

[13] G.J. Vasconcelos, T.V. Spina, H. Pedrini, Low-cost domain adaptation for crop and weed segmentation, in: Iberoamerican Congress on Pattern Recognition, Springer, 2021, pp. 141-150.

[14] S.M. Pizer, E.P. Amburn, J.D. Austin, R. Cromartie, A. Geselowitz, T. Greer, B. ter Haar Romeny, J.B. Zimmerman, K. Zuiderveld, Adaptive histogram equalization and its variations, Comput. Vis. Graph. Image Process. 39 (3) (1987) 355-368.

[15] Y. Yang, D. Lao, G. Sundaramoorthi, S. Soatto, Phase consistent ecological domain adaptation, in: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020, pp. 9011-9020.

[16] O. Ronneberger, P. Fischer, T. Brox, U-Net: convolutional networks for biomedical image segmentation, in: International Conference on Medical Image Computing and Computer-Assisted Intervention, Springer, 2015, pp. 234-241.

[17] K. Simonyan, A. Zisserman, Very deep convolutional networks for large-scale image recognition, arXiv preprint, arXiv:1409.1556, 2014.

[18] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, L. Fei-Fei, ImageNet: a large-scale hierarchical image database, in: 2009 IEEE Conference on Computer Vision and Pattern Recognition, IEEE, 2009, pp. 248-255.

[19] M.A. Rahman, Y. Wang, Optimizing intersection-over-union in deep neural networks for image segmentation, in: International Symposium on Visual Computing, Springer, 2016, pp. 234-244.

[20] D.P. Kingma, J. Ba Adam, A method for stochastic optimization, arXiv preprint, arXiv:1412.6980, 2014.

[21] J.W. Cooley, J.W. Tukey, An algorithm for the machine calculation of complex Fourier series, Math. Comput. 19 (90) (1965) 297-301.

[22] I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, Y. Bengio, Generative adversarial networks, Commun. ACM 63 (11) (2020) 139-144.

[23] Rose challenge, http://challenge-rose.fr/en/home/. (Accessed 3 January 2023).

[24] R. Bertoglio, A. Mazzucchelli, N. Catalano, M. Matteucci, A comparative study of Fourier transform and CycleGAN as domain adaptation techniques for weed segmentation - code and data, https://doi.org/10.17632/x8brgg2j28.2, 2023.