# A morphological segmentation approach to determining bar lengths

Mitchell K. Cavanagh,1 Kenji Bekki1 and Brent A. Groves1,2
1International Centre for Radio Astronomy Research, The University of Western
Australia, 7 Fairway, Crawley, WA 6009, Australia
2Research School of Astronomy and Astrophysics, Australian National
University, Mt Stromlo Observatory, Weston Creek, ACT 2611, Australia
E-mail<EMAIL_ADDRESS>(MKC)

(Accepted XXX. Received YYY; in original form ZZZ)

###### Abstract

Bars are important drivers of galaxy evolution, influencing many physical
processes and properties. Characterising bars is a difficult task, especially
in large-scale surveys. In this work, we propose a novel morphological
segmentation technique for determining bar lengths based on deep learning. We
develop U-Nets capable of decomposing galaxy images into pixel masks
highlighting the regions corresponding to bars and spiral arms. We demonstrate
the versatility of this technique through applying our models to galaxy images
from two different observational datasets with different source imagery, and
to RGB colour and monochromatic galaxy imaging. We apply our models to analyse
SDSS and Subaru HSC imaging of barred galaxies from the NA10 and SAMI
catalogues in order to determine the dependence of bar length on stellar mass,
morphology, redshift and the spin parameter proxy $\lambda_{R_{e}}$. Based on
the predicted bar masks, we show that the relative bar scale length varies
with morphology, with early type galaxies hosting longer bars. While bars are
longer in more massive galaxies in absolute terms, relative to the galaxy disc
they are actually shorter. We also find that the normalised bar length
decreases with increasing redshift, with bars in early-type galaxies
exhibiting the strongest rate of decline. We show that it is possible to
distinguish spiral arms and bars in monochrome imaging, although for a given
galaxy the estimated length in monochrome tends to be longer than in colour
imaging. Our morphological segmentation technique can be efficiently applied
to study bars in large-scale surveys and even in cosmological simulations.

###### keywords:

galaxies: bar – galaxies: general – galaxies: structure – methods:
miscellaneous

††pubyear: 2023††pagerange: A morphological segmentation approach to
determining bar lengths–A

##  1 Introduction

Stellar bars are centrally-located, rectangular-shaped morphological
structures that have profound impacts on the physical, dynamical and
morphological evolution of their host galaxies (Sellwood & Wilkinson, 1993;
Abraham et al., 1999; Masters et al., 2011; Cheung et al., 2013; Conselice,
2014). Bars are known to influence gas dynamics and star formation (Shlosman &
Noguchi, 1993; Ellison et al., 2011; Fanali et al., 2015; Lin et al., 2020),
the redistribution of angular momentum (Weinberg, 1985; Athanassoula, 2005),
disc-halo interactions (Athanassoula, 2002; Valenzuela & Klypin, 2003),
secular evolution and bulge growth (Rautiainen et al., 2002; Kormendy &
Kennicutt, 2004; Jogee et al., 2005; Athanassoula, 2013; Kruk et al., 2018),
morphological transition and quenching (Masters et al., 2012; Spinoso et al.,
2017; Fraser-McKelvie et al., 2020b; Géron et al., 2021), and even AGN
activity (Shlosman et al., 1989; Alonso et al., 2014). Bars are present in the
majority of spiral galaxies. Observational estimates for the bar fraction
range from 55% to as high as 70% of all spiral galaxies (Eskridge et al.,
2000; Aguerri et al., 2009; Saha & Elmegreen, 2018), to around a third of all
galaxies (Nair & Abraham, 2010b). It is well established that the prevalence
of bars declines with increasing redshift (Sheth et al., 2008; Cameron et al.,
2010; Melvin et al., 2014; Kim et al., 2021). The bar fraction is also known
to vary with morphology and environment. Previous studies have found that bars
are most common in redder galaxies such as early-type spirals (Combes &
Elmegreen, 1993; Masters et al., 2011; Skibba et al., 2012; Vera et al., 2016;
Cervantes Sodi, 2017; Erwin, 2018), although other studies have asserted that
there are just as prevalent, if not more, in late-type spirals (Erwin, 2018;
Tawfeek et al., 2022). Bars are also known to be more common in dense
environments (Elmegreen et al., 1990; Marinova et al., 2009; Lee et al.,
2012). Lenticular galaxies are also known to host bars, albeit in much lower
fractions compared to spirals (Laurikainen et al., 2009).

Many studies have focused on the prevalence of bars and the properties of
barred galaxies, yet there is also much to be gleaned from studying the
properties of the bars in their own right. In particular, the length of a
galaxy bar is an important physical property that can provide important
insights into the nature of its current evolution, as well as its effects on
the host galaxy (Erwin, 2005; Hoyle et al., 2011; Erwin, 2019; Fraser-McKelvie
et al., 2020a; Géron et al., 2021). The length of a bar can be defined in
terms of its actual, absolute length (in units of length), or as a
dimensionless, normalised length with respect to the size of the galaxy, such
as the scale radius of the host galaxy disc $R_{d}$. This study examines the
bar length using both of these definitions. In particular, we will refer to
the absolute bar length as $L_{\text{bar}}$, and the relative bar length as
$L_{\text{bar}}/R_{d}$ where $R_{d}$ is the disc scale radius. Previous
studies have used bar length as a means for measuring the “strength” of
stellar bars (Aguerri et al., 1998; Géron et al., 2021). Furthermore, bar
length is known to vary significantly with the morphology of the host galaxy.
Studies based on both $N$-body simulations and observations of nearby barred
galaxies have determined that bars are typically shorter in late-type galaxies
(Elmegreen & Elmegreen, 1985; Combes & Elmegreen, 1993; Aguerri et al., 2009;
Erwin, 2019), with Erwin (2005) finding that bars are over twice as long in
early-type galaxies as opposed to late-type discs. One possible explanation
for this is the higher gas fractions in late-type galaxies, which can suppress
the growth of the bar (Bournaud et al., 2005; Berentzen et al., 2007;
Athanassoula et al., 2013). Bar lengths can serve as independent markers of
the properties of the host galaxies. In particular, studies have also
demonstrated the absolute bar length positively correlates with increasing
galaxy mass (Kormendy, 1979; Erwin, 2005; Díaz-García et al., 2016).
Curiously, previous observational studies examining the evolution of barred
galaxies have found little change in overall bar lengths with redshift (Sheth
et al., 2008; Kim et al., 2021).

To measure the length of a bar, it is first necessary to confirm the existence
of a bar through morphological classification. This can be achieved through
visual classification, whether by groups of expert astronomers or
crowdsourcing (Sheth et al., 2008; Nair & Abraham, 2010b; Masters et al.,
2011; Buta, 2013; Masters et al., 2021). There are also several, analytical
methods for classifying barred galaxies, including isophotal ellipse fitting
(Abraham et al., 1999; Laine et al., 2002; Erwin, 2005; Menendez-Delmestre et
al., 2007; Consolandi, 2016), Fourier analysis (usually of the $m=0$ and $m=2$
modes of the azimuthal light profile) (Elmegreen & Elmegreen, 1985; Ohta et
al., 1990; Aguerri et al., 1998; Odewahn, 2004; Garcia-Gómez et al., 2017),
and photometric structural decomposition (Reese et al., 2007; Durbala et al.,
2009; Weinzirl et al., 2009). Recent studies have also utilised non-parametric
deep learning models to classify barred galaxies (Abraham et al., 2018;
Cavanagh & Bekki, 2020; Cavanagh et al., 2022). Bar lengths are typically
measured through analytical approaches, most notably isophotal ellipse fitting
(Erwin, 2005; Gadotti & de Souza, 2006; Marinova & Jogee, 2007; Hoyle et al.,
2011) and photometric bulge/bar/disc decompositions (Gadotti, 2008; Durbala et
al., 2008). However, these parametric approaches often rely on significant
preprocessing and/or require auxiliary data in addition to galaxy imagery.

Over the last few years, deep learning techniques have increasingly been used
across wide range of applications within astronomy, ranging from
classification to regression to segmentation (Baron, 2019; Fluke & Jacobs,
2020; Huertas-Company & Lanusse, 2023). In this study, we propose a novel
technique for estimating bar lengths via image segmentation with deep
learning. We develop and train U-Nets: specialised convolutional neural
networks capable of pixel-level image segmentation. Specifically, we train two
U-Nets – one on RGB colour imaging, another on monochromatic imaging – to
decompose an image of a galaxy into pixel masks highlighting the locations of
spiral arms and stellar bars. It is then possible to estimate the length of
bars through performing ellipse fitting on these pixel masks. Unlike
parametric or analytical methods, such as isophotal ellipse fitting or Fourier
analysis, that rely on a choice of free parameters or criteria in order to
detect the presence of a bar, our U-Nets directly output a predicted bar mask
solely from the image of a galaxy, without the need for auxiliary data. Only
after the U-Net has extracted the bar mask from the image of a galaxy can
arbitrary thresholds be applied to estimate the bar length with varying
degrees of confidence.

Originally designed for biomedical imaging (Ronneberger et al., 2015), U-Nets
have been used in a broad range of applications including robotics, industrial
automation, self-driving cars and mass surveillance (see Minaee et al. 2020
for a recent, comprehensive survey). Recently, studies in astronomy have
adopted U-Nets for source detection, source deblending, image denoising and
deconvolution, and even the structural decomposition of galaxy components
(Boucaud et al., 2020; Hausen & Robertson, 2020; Sureau et al., 2020; Bekki,
2021; Vojtekova et al., 2021; Robertson et al., 2022), however there is yet to
be a study to specifically focus on stellar bars. With the U-Net models
introduced in this study, it is possible to directly output pixel masks
highlighting the regions corresponding to bars in barred galaxies simply
through analysing galaxy images. Our U-Nets are trained using crowdsourced
masks from the Galaxy Zoo 3D (GZ3D) dataset (Masters et al., 2021). To
demonstrate the versatility of these models, we apply these U-Nets to analyse
images of galaxies across two datasets with different galaxy imaging: the Nair
& Abraham (2010a) visual morphological catalogue (Sloan Digital Sky Survey RGB
cutouts), and the Sydney AAO Multi-object IFS (SAMI) survey DR3 (Croom et al.,
2021) (Subaru HyperSuprime Cam RGB cutouts; Aihara et al. 2022).

The structure of our paper is as follows. In § 2, we outline our methodology,
briefly summarising the datasets used in the study before discussing our U-Net
architecture, the data preprocessing and model training procedures, and the
full bar length estimation pipeline, showcasing the sequence of steps from
galaxy image to bar length. In § 3, we discuss our core results. We highlight
the inherent versatility of our deep learning-based approach through directly
applying the U-Net model to analyse images of barred galaxies from different
observational datasets, each based on different imagery. We examine the
predicted bar lengths with respect to various physical properties of galaxies,
including stellar mass, morphology and kinematics, as well as redshift. In §
4, we discuss the implications of these results on the formation and evolution
of bars, as well as the role they play in the evolution of their host
galaxies. In particular, we examine the changes in the distribution of bar
lengths over redshift, and how this relates to changes in galaxy size,
including with respect to morphology. Also in § 4, we examine the differences
between two U-Nets trained with colour imaging and monochrome imaging. In
particular, we show that it is still possible for the monochrome U-Net to
differentiate spiral arms from bars. We further discuss the utility and
limitations of our novel deep learning approach, as well as further avenues
for studying additional morphological subfeatures. Lastly, we summarise our
key findings in § 5.

##  2 Methods

###  2.1 Datasets

This study utilises images of galaxies from multiple datasets. Of these, the
most significant dataset is the GZ3D dataset (Masters et al., 2021) which is
used to train the U-Net models. Other galaxy images include SDSS imaging for
barred galaxies in the Nair & Abraham (2010a) morphological catalogue and HSC
imaging of galaxies from the SAMI survey DR3 (Croom et al., 2021). Here we
briefly summarise these datasets.

####  2.1.1 GZ3D

The Galaxy Zoo 3D dataset (Masters et al., 2021) is a dataset of crowdsourced
classification masks for 29,831 galaxies sourced from the initial Mapping
Nearby Galaxies at APO (MaNGA) survey target list (Bundy et al., 2015; Wake et
al., 2017). It is publicly available as a value-added catalogue in the SDSS
Data Release 17 (Abdurro’uf et al., 2022). Participants were tasked with
inspecting RGB colour galaxy images (SDSS cutouts) in a web-based interface
and painting over region(s) corresponding to the desired feature. These
features include core structural components such as spiral arms and galaxy
bars, as well as the locations of foreground stars and the approximate
location of the galaxy centre. The final masks for each galaxy are obtained by
aggregating the individual masks drawn by each volunteer contributor. The
resulting “count” masks are thus formatted such that the value of each pixel
corresponds to the number of contributors that explicitly marked that pixel as
belonging to the desired morphological feature.

For the purpose of this study, we are focused only on samples containing
spiral masks and/or bar masks. The aim is for our U-Nets to output both a
spiral and bar mask for a given image, rather than just a bar mask by itself.
This is to force the model to distinguish spiral arms and bars as being
distinct morphological features. The training data ultimately consists of the
galaxy images as inputs, with the spiral and bar masks as the labels, or
ground truth. We enforce a minimum confidence level by restricting our
training data only to GZ3D galaxies whose bar or spiral masks have been drawn
by at least three volunteer classifiers. This brings the total number of
suitable galaxies down from the 29,831 total to 7,965 galaxies. We note that
this does not completely preclude erroneous masks (as shown in Appendix A),
and that the choice of the minimum number of classifiers is ultimately a
trade-off between quantity and quality.

####  2.1.2 NA10

The Nair & Abraham (2010a) catalogue consists of morphological classifications
for 14,034 galaxies sourced from the SDSS Data Release 4. The catalogue
consists of galaxies brighter than 16 mag (extinction-corrected $g$-band)
between $z\approx 0.01$ and $z=1$. For the purpose of this work, our analysis
is restricted to the 2,612 barred galaxies as sourced from the catalogue. We
use SDSS gri band colour images resized to $128\times 128$ pixels so that they
can be input into our U-Net models. These cutouts were sourced from the latest
data release of the SDSS via the publicly accessible SkyServer web interface.

####  2.1.3 SAMI DR3

The Sydney AAO Multi-object IFS (SAMI) survey (Croom et al., 2012; Bryant et
al., 2015; Croom et al., 2021) is a large-scale integral-field spectroscopy
survey of several thousand nearby, low-redshift galaxies. This includes their
morphological classifications, which are described in Cortese et al. (2016),
along with several key kinematic observables including the spin parameter
proxy $\lambda_{R_{e}}$ (Brough et al., 2017; van de Sande et al., 2021). We
first select 5,536 nearby, low-redshift galaxies from SAMI DR3 (Croom et al.,
2021), specifically all galaxies from the Galaxy and Mass Assembly (GAMA)
survey DR3 input catalogue (Driver et al., 2011; Bryant et al., 2015). These
image cutouts were initially 360$\times$360 pixels in size (corresponding to
angular field of view of 60.48 arcseconds), however they were resized to
128x128 for use with the U-Net models. Although there are no explicit barred
or unbarred galaxies in the SAMI DR3 catalogue, we apply an existing deep
learning CNN, based on previous work, to classify all 5,536 galaxies as barred
or unbarred. For the bar classification, we use $g$-band HyperSuprime Cam
(HSC) (Aihara et al., 2022) images of all galaxies; this is since the bar
classifier model is specifically trained to classify $g$-band imaging. For
full details of this model, including its architecture and training, see
Cavanagh et al. (2022). We henceforth only consider galaxies that are
classified by this model as barred with a certainty greater than 50%. For the
purposes of bar extraction with the U-Net, we use the RGB cutouts of the
galaxies classified by our bar model as barred. These RGB cutouts are publicly
accessible as part of the HSC Public Data Release 3, courtesy of the NAOJ/HSC
collaboration (see also Aihara et al. 2022).

###  2.2 The U-Net Model

Figure 1: A simplified schematic of our U-Net architecture, showing all core
layers, with arrows indicating the direction of data progression. Tuples in
parentheses indicate the output dimensions of the indicated layer, with the
rightmost digit indicating the number of channels. Each of the five top-most
blocks consist of alternating Conv2D and MaxPool2D layers; each of the five
bottom-most blocks consist of alternating Conv2D and Upsampling2D layers.

####  2.2.1 Model Architecture

A U-Net is a type of specialised convolutional neural network specifically
designed for image segmentation. A full treatment of CNNs is beyond the scope
of this paper, however we will give a brief conceptual overview of their
operation below (for a thorough treatment of CNNs, see LeCun et al. 2015;
Goodfellow et al. 2016; Chollet 2021). In a typical CNN, for instance one
designed for image classification, the model takes an image as an input, then
applies successive layers of convolutional filters to progressively extract
abstract features from the images, as well as pooling layers to progressively
downsample the outputs. In the case of image classification, the final output
is often an array of probabilities; one for each possible image category. The
values for these output probabilities are also known as confidences.

In the case of the U-Net, the input and output are both images. U-Nets can be
thought of as a regular CNN turned back on itself. The input image is first
progressively convolved and downsampled into a latent information bottleneck,
before a new image is reconstructed through the use of additional convolutions
and upsampling layers. Figure 1 shows a simplified schematic of our core U-Net
archiecture, clearly showing how the two halves downsample the input image,
then reconstruct the output images. At first glance, this architecture appears
to resemble the structure of a classical autoencoder (indeed, the principle of
learning a low-dimensional representation is exactly the same). However, what
distinguishes U-Nets from an autoencoders the presence of residual links, also
known as skip connections. These links preserve a copy of the outputs of a
given layer, such that they can be reincorporated into the input of a
downstream layer. Not only do these residual layers allow for the training of
much deeper networks through improved gradient propagation (He et al., 2015)
but, in the contexts of U-Nets, they also help to condition the upsampling
process by directly retaining the high-level features learned in the
downsampling process. This is a crucial reason behind the tremendous success
of U-Nets at image segmentation (Minaee et al., 2020).

Our core architecture, shared by both the RGB colour and monochromatic U-Nets,
consists of eleven convolutional layers (five each for the downsampling and
upsampling process, plus one for the output layer). Each convolutional layer
employs a kernel size of 3. LeakyReLU activation functions are used
throughout, with sigmoid activation for the output layer. Batch normalisation
is also used for all convolutional layers except for the output layer. There
are two residual links connecting convolutional layers with equal output
dimensions via element-wise addition (this is done using Keras’ Add layer).
The information bottleneck is a fully-connected Dense layer with 128 nodes;
this is the hence dimension of the smallest latent space of the model. The
only architectural difference between our two U-Nets is the number of channels
in the input layer, which results in an extremely negligible increase in the
number of trainable parameters for the colour U-Net (2,459,586), compared to
the single-channel input, monochrome U-Net (2,459,522).

####  2.2.2 Data Preprocessing & Model Training

Figure 2: Example application of the U-Net to six randomly selected galaxies
from the GZ3D test set; two barred spirals, two unbarred spirals, and two
barred galaxies without GZ3D spiral masks. Each row shows the input GZ3D
colour cutout, the volunteer-drawn GZ3D spiral and bar masks, and the
subsequent predicted spiral and bar masks as directly outputted by the U-Net.
The image cutouts are annotated with their GZ3D ID in the top-left. Different
shades in the GZ3D count masks correspond to different numbers of classifiers;
darker colours indicate higher degrees of overlap. The U-Net outputs attempt
to emulate the count masks as closely as possible, but are much smoother since
the pixel values are continuous. Figure 3: Contours defined by applying
different local thresholds to the predicted bar masks for a random selection
of GZ3D cutouts from the test set. Note that the image scale for the contours
has been magnified by a factor of two.

The GZ3D masks were obtained through crowdsourcing as part of the wider
Zooniverse citizen-science project. As previously described in Section 2.1.1,
each contributor was tasked with drawing pixel masks corresponding to the
locations of bars and spirals. The final mask is hence determined through
aggregating all the masks together (see Masters et al. 2021 for further
details). As such, there are inevitably regions where the masks from multiple
individual classifiers overlap. The degree of overlap can be considered as a
proxy of confidence, in the sense that multiple volunteer contributors are in
agreement. This information therefore ought to be incorporated into the deep
learning model. Indeed, a key difference of our U-Nets is that instead of
directly outputting a discrete-valued integer pixel mask, as is commonly done
in image segmentation, our U-Nets output continuous values for each pixel,
such that larger values indicate higher degrees of confidence. This is akin to
pixel-level regression rather than pixel-level classification. This method
allows us to account for, and ultimately preserve, the differing degrees of
overlap in the aggregate count masks in the GZ3D. Were the U-Net instead
configured to output integer values, then this information would be lost.
Another benefit of configuring the U-Nets in this manner is that this allows
arbitrary thresholds to be applied to the outputs of the model. If the model
were instead trained with binary pixel masks, then a threshold must have been
pre-applied to the training data. All subsequent applications of the model
would then be contingent on this pre-applied threshold. Instead, our approach
is for the U-Net to reproduce the GZ3D count masks.

The data preprocessing first commences by processing the raw fits files for
each of the 7,965 galaxies in our GZ3D sub-sample, publicly accessible as part
of the SDSS DR17 catalogue (Abdurro’uf et al., 2022). The RGB colour cutouts
of each GZ3D galaxy were generated from gri SDSS imaging with a pixel scale of
0.099 arcsec/pixel at a size of 525x525 pixels, corresponding to an angular
field of view of 52 arcsecs (Masters et al., 2021). Note that we will
hereafter refer to these colour images as RGB, keeping in mind that they
correspond to gri photometric bands. The count masks share the same initial
size of 525x525 pixels. We first apply a centre crop with a border width of 32
pixels, resulting in images of size 461x461 pixels; this serves to trim part
of the background and better focus in on the galaxy, while subsequently
enlarging the masks. The images are then resized to our U-Net’s input size of
128x128 pixels using the default bi-cubic interpolation settings with Python’s
Pillow package. All pixel values, including for the count masks, are rescaled
such that they are within the range 0 to 1, as is conventional for deep
learning. In the case of the images, all pixel values are divided by 255. For
the count masks, each pixel value is instead divided by the largest pixel
value out of all masks, which by definition is the maximum number of volunteer
classifiers $N_{\text{max}}$. Note that the bar and spiral count masks are
rescaled separately. Furthermore, under this formulation, the count mask
values are not probabilities, but simply rescaled aggregate counts. For
instance, if for one galaxy 4 out of 4 classifiers marked a given pixel as
”barred”, then it will have the same rescaled pixel value 4/$N_{\text{max}}$
as one in another galaxy that 4 out of 8 classifiers marked as barred. An
alternative formulation is to consider count fractions, in which the previous
4/4 and 4/8 examples would therefore have pixel values of 1 and 0.5
respectively. However, this would give a disproportionately high weight to
masks with low volunteer counts. Thus, in order to best replicate the count
masks, we just perform linear scaling.

We partitioned the images and labels into train and test sets using a ratio of
85:15; that is, 85% of the 7,965 galaxies are used to train the model, and the
remaining 15% are used to evaluate the model. These same partitions were used
to train the colour and monochromatic U-Net. In the case of the monochromatic
U-Net, the galaxy images were converted to monochrome using Pillow. The models
are trained for up to 100 epochs with Keras’s EarlyStopping callback. This
callback terminates the training if the loss has not improved over the
previous $n$ epochs, where $n$ is commonly referred to as the patience. We use
a patience of 11.

Figure 4: Overview of the full sequence of steps in our bar length estimation
pipeline. First, the U-Net is applied to an image of a galaxy. The U-Net
subsequently outputs a smooth bar mask with continuous pixel values that are
proxies for different levels of confidence. The next step is to choose a
threshold with which to convert this continuous bar mask into a binary pixel
mask. The final step involves ellipse fitting of the integer-valued pixel mask
to calculate the length of the major axis.

Figure 2 demonstrates the capabilities of the fully-trained U-Net at
replicating the GZ3D count masks. One immediately noticeable difference is the
smoothness of the predicted spiral masks, which reflect the interpolation
utilised in the upsampling process. It is also clear that the predicted spiral
masks are highlighting regions of the image that correspond to the presence of
a spiral arm rather than tracing out the spiral arm, hence the more patchy
appearance. This is most prominently seen in the fifth row of Figure 2, in
which the predicted spiral mask picks out the faint spiral arms despite there
not being any provided mask in the GZ3D. Even though this is a desirable
outcome, issues with the GZ3D masks (or lack thereof) like this do adversely
impact the training of the model. We will discuss these errors and the
performance of the model on corrupt or missing masks in Appendix A. Figure 2
also illustrates the importance of having configured the U-Net to output
separate masks for bars and spirals. In general, the predicted bar and spiral
masks are well separated. In some cases the spiral mask clearly leave a gap
for where the bar should be. The predicted bar masks are smooth and correctly
match the orientation of the bars, completely eliminating the blocky nature of
the GZ3D bar masks while retaining differences in confidence levels. In the
third and fourth rows of Figure 2, which show the outputs for unbarred
galaxies, the bar masks have substantially smaller pixel values, instead
tracing an echo of the galaxy. Interestingly, we see in the fourth example
that the bar mask appears to highlight the locations of the two foreground
stars. This suggests that the bar mask outputs may be sensitive to redder
colours, as bars are generally redder than the rest of the host galaxy, let
alone predominantly blue, star-forming spiral arms. We will discuss these
points, and how the monochromatic U-Net fares in the absence of colour, in
Section 4.3.

###  2.3 Bar Length Estimation

As aforementioned, the direct outputs of the U-Net are not discrete, binary
integer masks, but continuous values that correspond to degrees of confidence,
as has been illustrated in Figure 2. Indeed, since the U-Net was trained
directly on the GZ3D count masks, the total range of pixel values within a
given mask will vary from galaxy to galaxy. This includes cases where the
outputted pixel values are extremely tiny, notably in the two unbarred
galaxies in the middle two rows Figure 2. It is therefore desirable to discard
masks whose pixel values are too small. Our bar estimation pipeline thus
includes two thresholds:

  * •

A global threshold in order to discard bar masks whose pixel values are too
small.

  * •

And a local threshold to decide which pixels to keep in the current bar mask.

Specifically, a bar mask is chosen if its largest pixel is at least some
fraction of the maximum pixel value across all bar masks for the given
dataset. This is the role of the global threshold, the purpose being to
enforce a minimum threshold for the quality of a predicted bar mask (c.f.
middle two rows of Figure 2. For this study we set it at 10%. Once we’ve
selected a mask, we need to convert it from the continuous-valued mask into a
discrete, 0-1 binary mask. This is the role of the local threshold, which is
defined as some fraction of the maximum pixel value in the mask. Pixels
greater than this value are set to 1, the rest are set to 0. Here, a threshold
of 50% means that only pixels whose value is greater than half the value of
the largest pixel (in the current mask) are set to 1, with all other pixels
set to 0. Given that the U-Net is trained to reproduce the count masks, this
is analogous to choosing to retain only the regions of overlap shaded by more
than half of the volunteer classifiers (for a given galaxy). For this study,
we set the local threshold at 50%. Defining both these local and global
thresholds as fractions allows our algorithmic approach to automatically
process bar masks for any arbitrary set of galaxy images, irrespective of the
ranges of pixel values.

Figure 3 shows the impacts of applying different local thresholds to the
predicted bar masks. In general, higher thresholds extract progressively
smaller regions, while lower thresholds are more susceptible to error and
variation, in some cases tracing the spiral arm. The bottom-most example of
the central column in Figure 3 shows that the U-Net is susceptible to
companion sources, but a suitably high threshold can mitigate this. However,
at very high thresholds, it can be seen that the extent of the bar is severely
underestimated. This motivates our use of 0.5 as a local threshold. It should
be stressed that the local threshold is merely a way to define consistent
quantiles of the U-Net outputs. This is since the count masks have different
ranges of values as not all galaxies were classified by the same number of
volunteer classifiers. If instead the count masks were converted to
probabilities, then a local threshold would still be necessary, albeit instead
defined as a fixed probability value (e.g. 0.5) instead of a percentage.

Figure 5: Predicted bar and spiral masks as directly outputted by the U-Net
for a random selection of NA10 galaxies and SAMI galaxies. NA10 and SAMI
cutouts are annotated with their spID and SAMI catalogue IDs respectively.

Once the binary mask is obtained via the local threshold, the next step is to
perform ellipse fitting. For this, we utilise scikit-image’s measure module to
automatically perform the ellipse fitting, and measure the length of the bar
by measuring the major axes of the fitted ellipse (van der Walt et al., 2014).
More specifically, we use the label function to detect and label connected
pixel regions (i.e. neighbouring pixels that share the same value) in the
resulting binary pixel bar mask. This is followed by the regionprops function,
which enables us to subsequently estimate the bar length based on the length
of the major axis of the fitted ellipse assigned to this connected region. Our
choice of using the routines from the scikit-image package to carry out the
ellipse fitting is motivated by the fact that these functions are specifically
designed for discrete integer-valued masks. We note that this choice is by no
means exclusive, and that the ellipse fitting of the pixel mask can feasibly
be conducted with other image processing libraries such as opencv. By this
stage in the overall estimation pipeline, the estimated bar length is in units
of pixels, which can be converted into a physical length based on the (per-
pixel) physical scale of the corresponding image. Figure 4 illustrates the
full sequence of steps for two example barred galaxies from the NA10 and SAMI
datasets. The entire pipeline is fully automated, requiring only the global
and local thresholds for bar mask filtering and extraction respectively, which
in our case were set to 0.1 and 0.5.

It is worth noting that our choice of carrying out binary-pixel mask
extraction by applying a threshold is merely one approach to estimating the
bar length. It is also feasible to obtain the pixel mask through using
traditional isophotal ellipise fitting of the smooth masks directly outputted
by the U-Net (i.e. after Step 1 in Fig 4), or indeed through applying ellipse
fitting to the original galaxy image in the first place. That said, compared
to isophotal ellipse fitting – and parametric fitting methods in general – our
U-Net approach to bar detection has several key benefits and drawbacks. One of
the immediate benefits is that it is computationally efficient; the bar mask
is directly obtained without the need for an iterative fitting process.
Furthermore, there is no need to specify initial conditions as there are no
free parameters (c.f. Aguerri et al. 2009). This allows us to apply the U-Net
to readily and rapidly extract bar masks for thousands of galaxies across
different datasets in less than a minute; specifically, $\approx$10 seconds
for the NA10 galaxies, and $\approx$16 seconds for the SAMI galaxies. Our use
of scikit-image’s measure model enables us to quickly determine many physical
metrics for the bar apart from its semi-major axis, such as spatial moments
and pixel area, the latter of which is extremely useful for determining mass
fractions (we will discuss additional applications of the U-Net in Section
4.4). That the U-Net is trained solely on the images of galaxies (paired with
their respective spiral and bar masks) without any additional hard-coded
assumptions or auxiliary information is a fundamental advantage of deep
learning methods in general. However, due to the sole reliance on the training
data, this can lead to limitations in the model’s ability to generalise. This
is best illustrated in the previously discussed example of Figure 2, where the
bar mask is sensitive to red foreground stars, or in Figure 3 where, at low
thresholds, the predicted “bar” mask appears to protrude along spiral arms.
The concept of a “bar” is, from the point of view of the U-Net, simply the
features of a galaxy image that correspond to regions that have been labelled
as such across the thousands of GZ3D bar masks it has been trained on. As such
there is the potential for greater uncertainty when compared to a parametric
approach, such as isophotal ellipse fitting or Fourier analysis.

##  3 Results

Figure 6: Central coordinates (denoted by red markers) and estimated bar
lengths $L_{\text{bar}}$ (shown with white lines oriented according to the
predicted bar mask) for a random selection of NA10 and SAMI galaxies is
ascending order. Cutouts annotated as in Figure 5. Figure 7: Predicted bar and
spiral masks as directly outputted by the U-Net for a random selection of NA10
galaxies and SAMI galaxies. NA10 and SAMI cutouts are annotated with their
spID and SAMI catalogue IDs respectively.

###  3.1 Application of the U-Net

We first apply our fully-trained U-Net to extract bar masks for galaxies from
the NA10 morphological catalogue and SAMI DR3. As an additional measure of
confidence, before processing each image with the U-Net, we verified that the
image is barred by classifying it with our bar CNN. This extra step did not
affect the SAMI bars (which were classified by the model in question), but
this did exclude approximately 2.5% of the known NA10 bars, which is well
within the 83% accuracy of the bar model (see Cavanagh et al. 2021).

Figure 5 illustrates the predicted spiral and bar masks for a selection of
galaxies from NA10 and SAMI. It can be seen that the model performs
consistently well on the two different source imagery. Despite being trained
on SDSS imaging, the U-Net is also able to extract bar masks for HSC imaging.
There is, however, a higher degree of overlap in the predicted spiral masks
with the central bar region. The predicted spiral mask is also sensitive to
galaxy rings, as shown with the predicted masks for the SAMI galaxy with ID
584716. This can be considered an undesirable side effect given the model is
ostensibly trained to solely extract spiral arms, but it nevertheless
demonstrates how the U-Net works in principle by responding to features in the
image. That said, spiral arms are an incredibly diverse morphological feature
and can manifest in a variety of structures and forms, whilst bars are
comparatively more uniform. Indeed, the predicted bar masks in Figure 5 are
all smooth and correctly oriented. It is also encouraging that the extracted
bar masks all highlight a single region in the image, despite some instances
of visual interference or neighbouring sources, such as in the NA10 galaxy
422-51811-148.

Figure 8: The absolute bar length $L_{\text{bar}}$ in terms of stellar mass,
bar classification confidence $P_{\text{bar}}$, redshift $z$, the spin
parameter proxy $\lambda_{R_{e}}$, NA10 T-Types and SAMI T-Types. NA10 and
SAMI galaxies are coloured in dark red and dark blue respectively. Error bars
denote one standard error $\sigma$.

Having now obtained the bar masks for the NA10 and SAMI galaxies, the bar
length estimation pipeline can proceed. Figure 6 shows a selection of galaxies
marked with the estimated bar length based on the fitted ellipse as per
scikit-image’s measure module. The SDSS imaging all have the same physical
scale of 50 kpc, while the HSC cutouts vary in physical scale. In general, the
markers are well aligned with the galaxy centres, and the predicted semi-major
axes are correctly oriented. There are some instances where the centre is
slightly offset. This is possibly due to one side of the predicted bar mask
having a higher overall confidence than the other side, subsequently
offsetting fitted ellipse. This does not appear to significantly affect the
overall length of the bar. It is also worth keeping in mind the inherent
uncertainty of where the bar ends and where the spiral arm begins (as
previously shown in Figure 3), which could lead to an overestimated
$L_{\text{bar}}$ in the case of strong spiral galaxies.

Figure 5 shows that the U-Net can successfully process both SDSS and HSC
imaging. However, there remains the question of consistency, and whether there
are any major differences. We can examine this by applying the U-Net to
extract spirals and bars from SDSS and HSC imaging of the same galaxy. There
are exactly four barred galaxies in the NA10 catalogue that are also present
in our SAMI DR3 subsample. These are shown in Figure 7, along with the
predicted spiral and bar masks. The first immediate difference is the
different angular resolutions, however the U-Net is nevertheless able to
extract masks, even at the edges of the image. However, the bar masks are less
uniform. This is especially problematic in the case of galaxy 106638, where
the U-Net model has difficulty extracting the centre of the bar, possibly due
to it being obfuscated by the large central bulge. In 288992 and 65406, the
predicted bar masks appear to trace the spiral arms (this effect can be
removed with a suitably large local threshold). It is interesting to note how
the U-Net handles the image artefacts in 288992; the horizontal line through
the centre of the galaxy does not appear to affect the predicted bar mask,
while the model does not output anything in the red band artefact region. The
estimated bar lengths from the predicted bar masks are 15.6, 6.83, 8.19 and
7.61 kpc for the SDSS imaging, and 0 (skipped due to being below the global
threshold), 5.78, 6.33 and 8.38 kpc for the HSC imaging respectively. The
discrepancies in bar length directly follow from the discrepancies in the
output bar masks and, more specifically, the threshold contours.

###  3.2 Physical Properties

Bar length, also denoted $L_{\text{bar}}$, is a key physical property of
stellar bars. Understanding how bar length varies with respect to the
properties of the host galaxy can yield important insights into the processes
that govern the growth, evolution and impacts of bars (Combes & Elmegreen,
1993; Gadotti & de Souza, 2006; Hoyle et al., 2011; Guo et al., 2019; Fraser-
McKelvie et al., 2020a). The bar length $L_{\text{bar}}$ is one of several
phenomenological criteria often used to judge the “strength” of a stellar bar
(Aguerri et al., 1998; Guo et al., 2019; Géron et al., 2021). Previous studies
have shown that the bar length tends to scale with the mass of the host
galaxy, and may also change depending on the morphology of the galaxy with
larger bars in early-types and shorter bars in late-types (Erwin, 2005; Díaz-
García et al., 2016; Erwin, 2019). It is worth noting that the absolute bar
length $L_{\text{bar}}$ is not necessarily the ideal quantity to meaningfully
study the lengths of bars across different galaxies with different physical
properties. In particular, a large bar in a small galaxy may share the same,
absolute length as a small bar in a large galaxy, but they are clearly sized
differently in relation to their host galaxy. To take the size of the host
galaxy into consideration, we can define a normalised, relative bar length by
considering the dimensionless quantity $L_{\text{bar}}/R_{d}$ where $R_{d}$ is
the scale radius of the galaxy disk, also known as the scale length. In the
case of the SAMI galaxies, $R_{d}$ is calculated from the effective radius
$R_{e}$ as $R_{d}\approx R_{e}/1.68$. For the NA10 galaxies, $R_{d}$ is
similarly calculated from the effective radius $R_{e}$, which is approximated
from the Petrosian half-flux radius $R_{50}$ and concentration $R_{90}/R_{50}$
using the method in Graham et al. (2005).

Figure 9: The same plots as in Figure 8, but instead showing the normalised,
relative bar length $L_{\text{bar}}/R_{d}$.

Figure 8 shows a series of plots for the absolute bar length $L_{\text{bar}}$
with respect to stellar mass, the bar classification confidence
$P_{\text{bar}}$ based on the bar CNN model from Cavanagh et al. (2022),
redshift, $\lambda_{R_{e}}$, as well as morphology in terms of the NA10
T-Types (themselves based on Hubble T-Types), as well as the SAMI T-Types
described in Cortese et al. (2016). Likewise, Figure 9 examines the same
properties for the relative bar length $L_{\text{bar}}/R_{d}$. It can be seen
that $L_{\text{bar}}$ increases strongly with stellar mass
$\log(M_{\star}/M_{\odot})$, a trend that has been well established in
observations (Kormendy, 1979; Erwin, 2005; Díaz-García et al., 2016). However,
when considering the size of the host galaxy, the trends are mixed between the
two datasets. In the case of NA10, there is a significant drop in the relative
bar length $L_{\text{bar}}/R_{d}$ for high mass galaxies; bars are longer in
high mass galaxies, but shorter with respect to the host galaxy. On the other
hand, the relative bar length trends upwards for the SAMI galaxies, with
significant variation. That said, it is important to note that the two
datasets sample different mass ranges, and that the mass distributions are
different. Studies have shown that disc scale radius increases with stellar
mass, suggesting that as a host galaxy grows, so too does its bar, albeit not
necessarily with respect to its disc (Díaz-García et al., 2016; Kruk et al.,
2018; Fraser-McKelvie et al., 2020a; Rosas-Guevara et al., 2022). This could
also be reflective of higher bulge-to-disk ratios for more massive galaxies.
It is argued in Erwin (2019) that difficulties in detecting shorter bars may
result in their underestimation in low mass galaxies. Erwin (2018) also makes
the argument that limited image resolution affects the ability to detect bars.
This could be a reason as to why $L_{\text{bar}}/R_{d}$ remains high for low
mass galaxies in Figure 9, in the sense that the U-Net is better suited to
extracting the largest of bars while missing smaller bars. We will return to
this point when discussing galaxy size in more detail in Section 4.

Comparing $L_{\text{bar}}$ with the classification confidence $P_{\text{bar}}$
provides a means of assessing biases. Here, $P_{\text{bar}}$ is the confidence
that the model is barred, as predicted by the bar CNN (this is separate from
the U-Net). In the case of NA10, there is a slight increase in
$L_{\text{bar}}$ with high $P_{\text{bar}}$ galaxies, suggesting that longer
bars are more confidently classified. For SAMI this trend is reversed, with
longer bars in low $P_{\text{bar}}$ galaxies. This is likely reflective of the
different source imaging and, subsequently, different uncertainties, similar
to what was observed in Figure 3 with lower thresholds. The predicted bar mask
for a low-confidence bar galaxy may well be larger than for a high-confidence
bar galaxy, not because the bar is longer, but because the extracted bar mask
is itself larger out due to the greater uncertainty. Indeed, Figure 9 shows
that $L_{\text{bar}}/R_{d}$ is highest for low $P_{\text{bar}}$ galaxies in
both the NA10 and SAMI datasets. This is, of course, subject to the
interpretation of $P_{\text{bar}}$ as an indicator for how easy it is to
identify a galaxy as barred (see also Cavanagh et al. (2022) where it is
argued that $P_{\text{bar}}$ is a proxy for bar strength).

Figures 8 and 9 also show how the bar length varies terms of redshift $z$ and
the spin parameter proxy $\lambda_{R_{e}}$. In the case of NA10, we can
observe that while $L_{\text{bar}}$ increases with increasing $z$,
$L_{\text{bar}}/R_{d}$ dramatically decreases. This is in stark contrast to
SAMI, where we see an increase in both $L_{\text{bar}}$ and
$L_{\text{bar}}/R_{d}$ with $z$. There are many factors that can influence the
lengths of bars with redshift, not least the morphological evolution of the
host galaxy. However, previous studies examining bars out to high redshifts
have found that bar lengths (both absolute and normalised length) do not show
any significant changes with redshift (Sheth et al., 2008; Kim et al., 2021),
implying that bars scale proportionally with their host galaxy as both evolve
over time. The results of Figures 8 and 9 suggest that this might not be so
clear-cut.

Figure 10: The dependence of the relative bar length $L_{\text{bar}}/R_{d}$ on
stellar mass $\log(M_{\star}/M_{\odot})$ for different local thresholds as
applied to the predicted bar mask.

The spin parameter proxy $\lambda_{R_{e}}$, originally introduced in Emsellem
et al. (2007), is a key kinematic property of galaxies. This dimensionless
parameter acts as a proxy for the baryon projected specific angular momentum
and therefore represents a luminosity-weighted ratio of ordered motion (i.e.
rotation) to random motion. $\lambda_{R_{e}}$ is not to be confused with the
classical, dynamical spin parameter $\lambda$ (Peebles, 1971), although the
former is a good approximator of the latter. Studies have utilised
$\lambda_{R_{e}}$ to better understand the dynamics of early-type galaxies
(Moran et al., 2007; Emsellem et al., 2011; Cappellari, 2016; Graham et al.,
2018) and stellar bars (Rawlings et al., 2020), as well as distinguish between
different morphologies (van de Sande et al., 2021). In the case of Figures 8
and 9, we find that $L_{\text{bar}}$ and $L_{\text{bar}}/R_{d}$ exhibit
opposite trends with respect to $\lambda_{R_{e}}$. In the case of the absolute
bar length, we see a steady increase with increasing $\lambda_{R_{e}}$.
However, when normalised with respect to the scale radius of the galaxy, we
find that bars are actually longer in low-spin galaxies. This particular
result is consistent with the analysis of bars based on the classical spin
parameter in Cervantes-Sodi et al. (2013), in which low spin galaxies are more
prone to self-interacting gravitational instabilities (Combes & Sanders, 1981;
Sellwood & Wilkinson, 1993; Athanassoula, 2003), compared to the high ordered
rotation found in galaxies with higher spin parameters. That the trends are
reversed also implies that low-$\lambda_{R_{e}}$ galaxies tend to be
physically larger than their high-$\lambda_{R_{e}}$ counterparts. Indeed, it
is known that $\lambda_{R_{e}}$ depends strongly on morphology, in that early
type galaxies tend to have low $\lambda_{R_{e}}$ values compared to late type
galaxies (Emsellem et al., 2007; van de Sande et al., 2021). It is thus
possible that disc scale radii $R_{d}$ may more strongly dependent on the spin
parameter $\lambda_{R_{e}}$ compared to the lengths of bars $L_{\text{bar}}$
by themselves.

On that note, Figures 8 and 9 show how the bar length varies with morphology.
In the NA10 case, we can see that bars are longest in early-type galaxies,
specifically lenticular and early spirals. There is a sharp reduction in both
$L_{\text{bar}}$ and $L_{\text{bar}}/R_{d}$ towards later morphological types,
before a slight increase in bar lengths for very late spiral galaxies. That
bars are shorter in late type galaxies compared to early type galaxies has
been well established by previous studies, based on both observations of
nearby galaxies and $N$-body simulations (Elmegreen & Elmegreen, 1985; Combes
& Elmegreen, 1993; Aguerri et al., 2009; Erwin, 2005, 2019). For the SAMI
galaxies we see a peak bar length at SAMI T-Types 1.0 and 1.5 (S0 and S0/Early
Spiral respectively) with shorter bars in late spirals and E/S0, the latter of
which could likely be to the U-Net extracting bulges. One explanation for late
type galaxies having shorter bars is due to their higher gas content, which
can potentially suppress bar formation and/or slow the rate of growth of the
bar (Bournaud et al., 2005; Berentzen et al., 2007; Athanassoula et al.,
2013). The previous study by Hoyle et al. (2011) found a similar dependence of
bar size with colour, with redder, early-type galaxies hosting longer bars
than bluer, late-type galaxies. It is worth noting that the bar size
dependence in Figures 8 and 9 also correlates with an increasing bar fraction
in redder galaxies (Masters et al., 2011; Skibba et al., 2012; Vera et al.,
2016; Cervantes Sodi, 2017). However, the recent study by Tawfeek et al.
(2022) is a notable exception having found a peak bar fraction for more
massive, late-type galaxies (although this study did not examine bar size),
while Erwin (2018) also finds that bars are similarly just as frequent in both
gas-rich, bluer galaxies as gas-poor, redder galaxies.

Lastly, it is worth considering the impacts of applying different local
thresholds to the predicted bar mask on the overall bar lengths, and how this
may impact the previous discussion of physical properties. Recall that in
Figure 3 it was demonstrated that the different thresholds clearly impact the
estimated bar length by retaining different regions of the predicted bar mask;
larger thresholds result in smaller bar lengths. Figure 10 shows how
different, equally-spaced local thresholds shape the dependence of
$L_{\text{bar}}/R_{d}$ on $\log(M_{\star}/M_{\odot})$. It can be seen that the
overall trends are almost identical with only minor variation, and that the
only key difference amounts to relatively constant scale factors when going
from one threshold to another. That the trends remain so similar suggests that
changing the local threshold merely changes the estimated length, and that the
predicted bar masks are otherwise evenly smooth and uniform. This further
implies that it is possible to calibrate a choice of threshold based on known
bar lengths for a given dataset.

Figure 11: The absolute bar length $L_{\text{bar}}$ in terms of the Petrosian
half-flux radius $r_{50}$ for the NA10 galaxies and effective radius $r_{e}$
for the SAMI galaxies. Points are coloured according to morphology, with the
probability densities displayed on the margins.

##  4 Discussion

###  4.1 Galaxy Size

Figure 12: Relative bar length $L_{\text{bar}}/R_{d}$ as a function of
redshift $z$ for NA10 barred galaxies in different mass ranges and for
different morphologies. Figure 13: Relative bar length $L_{\text{bar}}/R_{d}$
as a function of redshift $z$ for SAMI barred galaxies in different mass
ranges and for different morphologies. Figure 14: Probability density
distributions for the absolute bar sizes $L_{\text{bar}}$ and galaxy sizes
$r_{50}$ (NA10) and $r_{e}$ (SAMI) across different redshift ranges, separated
by morphological type.

So far we have established that the bar length varies with respect to various
physical properties including stellar mass and morphology. Although we have
examined the normalised, relative bar length $L_{\text{bar}}/R_{d}$, it is
worth examining the physical sizes of galaxies in their own right. Figure 11
illustrates the distributions of NA10 and SAMI galaxies, with their absolute
estimated bar length $L_{\text{bar}}$ plotted against their physical size,
grouped by morphology. Here, early spiral and late spiral designations are
grouped by dividing the spiral T-Type morphologies. In the case of NA10, our
early spiral group includes T-Types 2 through 4 (Sab to Sbc), with late spiral
containing T-Types 5 and above, excluding irregulars and miscellaneous
galaxies (Sc to Sm). For SAMI, the division is T-Types 2 and 2.5 (early
spiral, early/late spiral) for early spiral, and T-Type 3 (late spiral) for
late spirals, excluding indeterminate/unknown types. T-Type 1.5 (S0/early
spiral) was assigned to the S0 category in order to better balance the
partition. Note also that the definitions are not directly comparable due to
the inherent difference between the NA10 and SAMI T-Type definitions (Nair &
Abraham, 2010a; Cortese et al., 2016).

It can be seen in Figure 11 that there is significant scatter when it comes to
morphology, however it is still possible to disentangle both the NA10 and SAMI
datasets. As expected from Figure 8, the absolute bar length $L_{\text{bar}}$
tends to be shortest in late spirals, although the distributions for
$L_{\text{bar}}$ with respect to S0s and early spirals are a lot tighter. The
distribution of $L_{\text{bar}}$ is best separated with morphology in the SAMI
dataset. When it comes to galaxy size, the smallest galaxies in SAMI tend to
be late spirals, while the smallest galaxies in NA10 ($r_{\text{50}}\leq 2$
kpc) are overwhelmingly S0 galaxies. Galaxy size $r_{50}$ acts as fair
indicator of morphology, as evinced by their plotted probability
distributions, with S0s mostly present at low $r_{50}$, followed by late
spirals and then early spirals with increasing $r_{50}$. Curiously, there is a
very sharp drop in the number of late spirals with absolute bar lengths
$L_{\text{bar}}>10$ kpc.

The results of Figure 11 also better explain the dramatic differences in
trends with $L_{\text{bar}}$ and $L_{\text{bar}}/R_{d}$ with respect to
$\lambda_{R_{e}}$ that were established in Figures 8 and 9; in particular,
that low-$\lambda_{R_{e}}$ galaxies (predominantly early-type) tend to be
physically larger than their high-$\lambda_{R_{e}}$ counterparts
(predominantly late-type), at least with respect to the barred galaxies
examined in this study. There is yet to be a large-scale, systematic study of
the kinematic differences between barred and unbarred galaxies in SAMI,
however our results on bar lengths with respect to $\lambda_{R_{e}}$
demonstrates the importance of ordered rotation in limiting the length of
stellar bars with respect to the scale radius of its host galaxy. However, we
stress that the results of Figure 11 are necessarily dependent on sample
selection.

###  4.2 Evolution of Bar Length

Figure 8 and 9 demonstrated that bar length varies considerably with redshift,
with NA10 and SAMI exhibiting opposite trends in the case of the relative
length $L_{\text{bar}}/R_{d}$. In particular, the NA10 galaxies showed a
steady decline in relative bar length with increasing $z$, while the SAMI
galaxies showed an increase. Of course, the change in galaxy size over
redshift is also influenced by sample selection effects, and hence NA10 and
SAMI are not directly comparable. However, by examining the changes in bar
length over time with respect to other physical properties, such as stellar
mass and morphology, it is possible to glean further insights into what could
be driving this change.

Figure 12 examines the decline in the relative lengths of bars for barred
galaxies divided into different mass ranges and different morphological types.
Already it can be seen that NA10 only samples low to intermediate-mass
galaxies at relatively low redshifts, sampling only the most massive galaxies
at high $z$. Nevertheless, the relative bar length declines in all three mass
ranges, with the steepest decline for intermediate-mass samples between
$0.02<z<0.05$. In terms of morphology, we see that the bar length for S0s
exhibits the largest decline, from well over $2R_{d}$ at low redshift to
around $0.8R_{d}$ at $z\approx 0.08$. In general, the rate of decline in bar
length is highest at low redshift, which implies that the growth of stellar
bars is accelerating.

Figure 15: Illustration of the contours for the same galaxies as in Figure 3,
but this time showing the difference in the contours of the bar mask for the
RGB colour U-Net and the monochrome U-Net at a given local threshold.

We saw in the previous section that the SAMI galaxies exhibit different trends
compared to the NA10 galaxies. Indeed, Figure 13 shows the increase in
relative bar size with increasing redshift. Compared to Figure 12, there is
less overall separation for galaxies of different masses, with the low and
intermediate mass galaxies showing similar trends. We note that the mass
ranges in Figures 12 and 13 are slightly different; this is done to account
for the different sample selections and to ensure that the three mass range
groups each have a similar number of galaxies. Examining morphology, and again
lenticular galaxies have longer normalised bar lengths, with both the early
and late spiral morphological types having similar bar lengths for $z<0.05$,
beyond which bars in early spirals are longer. However, beyond $z>0.05$ there
are relatively few galaxies in the SAMI sample, hence the greater uncertainty.
That $L_{\text{bar}}/R_{d}$ is highest in S0s compared to the other types may
be reflective of higher baryonic fractions in S0s, possible as a result of the
gas stripping associated with their formation (Bekki & Couch, 2011). Thus bars
which may not have been as prominent in early spirals may be larger relative
to $R_{d}$ in S0s after having undergone a faded spiral morphological
transition (Rizzo et al., 2018; Deeley et al., 2020; Coccato et al., 2022).

Figure 16: Comparison of the estimated bar lengths $L_{\text{bar}}$ (mono) and
$L_{\text{bar}}$ (RGB) obtained from the predicted masks of the monochrome and
RGB colour U-Nets respectively. The vertical axis shows the ratio
$L_{\text{bar}}$ (mono) / $L_{\text{bar}}$ (RGB), with the black dotted line
denoting equal lengths. From left to right, the samples are coloured according
to stellar mass, galaxy size and morphology.

The reduction in $L_{\text{bar}}/R_{d}$ over time (as observed for the SAMI
galaxies) can be interpreted in two ways; that the bars are shrinking over
time, or that the host galaxies are shrinking. Given the previously
established results in Figure 8, this would suggest that the sizes are
shrinking over time. To confirm this, Figure 14 shows the changes in the
distributions of absolute bar lengths $L_{\text{bar}}$ and galaxy physical
sizes for both the NA10 and SAMI galaxies over different redshift ranges,
separated by morphological type. Indeed, this helps to clarify the results of
both Figures 12 and 13. In the case of SAMI, there is a large increase in
$L_{\text{bar}}$ with increasing $z$, which exceeds the corresponding increase
in galaxy physical size $r_{e}$ over the same $z$ intervals. This is why, for
SAMI, $L_{\text{bar}}/R_{d}$ increases with increasing $z$. However, in the
case of NA10, the overall distributions of bar lengths $L_{\text{bar}}$
remains relatively similar, with only a modest growth over time. However, the
physical sizes of NA10 galaxies differ dramatically with $z$. This is why, for
NA10, $L_{\text{bar}}/R_{d}$ decreases with increasing $z$.

It should be stressed that the changes in the distributions of galaxy physical
sizes are largely a consequence of sample selection, and care should be taken
to interpret this as representative of all galaxies with a given morphological
type in these redshift ranges. However, this may not wholly account for the
dramatic difference in the changes in the distributions of $L_{\text{bar}}$
between the NA10 and SAMI galaxies. In particular, it is curious to note how
the distributions of the different morphologies are relatively similar at low
redshifts, but become more distinct at higher redshifts in that the peaks of
each morphology are more separated. However, this divergence could also be a
side effect of low number statistics, as shown by the lack of any late spirals
in NA10 beyond $z>0.08$. Another explanation for the decline in
$L_{\text{bar}}/R_{d}$ with decreasing $z$ for the SAMI galaxies is the fact
that spirals account for almost all the SAMI galaxies with $L_{\text{bar}}<5$
kpc (as per Figure 11) and that, unlike the NA10 galaxies, the spirals in SAMI
all peak at the same physical size as lenticulars. Recall from Figure 9 that
spirals have shorter bars than lenticulars.

The results of Figures 12, 13 and 14 suggest that there is evolution in bar
lengths, both absolute and normalised, for nearby galaxies with redshifts
below $0.1$. However, it is important to contextualise this in terms of the
different sample selection criteria employed for the NA10 and SAMI surveys.
Both samples are biased towards more massive galaxies, well above
$10^{10}M_{\odot}$, at their highest redshift ranges (Nair & Abraham, 2010a;
Bryant et al., 2015). This is a key driver of the increase in galaxy sizes
with increasing redshift as observed in Figure 14, given that these more
massive galaxies tend to be physically larger. This selection effects have a
key impact on the evolution of $L_{\text{bar}}/R_{d}$ with $z$. Studies
examining galaxies out to higher redshifts have found little to no change in
normalised bar length, implying that bars continue to scale with their host
galaxies’ discs (Kim et al., 2021). Indeed, previous studies have established
that, as bars evolve over time, they tend to grow longer (Athanassoula, 2003;
Erwin, 2005; Hoyle et al., 2011; Díaz-García et al., 2016; Kruk et al., 2018).
Furthermore, it is also worth noting that observational studies have found
that the bar fraction declines with increasing redshift (Sheth et al., 2008;
Cameron et al., 2010; Melvin et al., 2014), with similar trends also found in
simulations (Algorry et al., 2017; Rosas-Guevara et al., 2019; Cavanagh et
al., 2022). The bar fraction is known to be greatest in spiral galaxies
(Eskridge et al., 2000; Aguerri et al., 2009; Saha & Elmegreen, 2018). Indeed,
the majority of the known bars in NA10 and predicted bars in SAMI are spirals
(see Figure 11).

###  4.3 Comparison of the RGB Colour & Monochromatic U-Nets

Although the GZ3D dataset provides RGB colour cutouts, this does not preclude
the possibility of training a U-Net to classify greyscale, monochromatic
imaging. Such a U-Net could enjoy wider applications to datasets where colour
imaging is not readily available, and/or potentially be utilised to examine
single bands individually. The purpose of this section is therefore to examine
the differences in both the predicted bar masks and estimated bar lengths
between the two U-Nets; one which uses RGB colour imaging as its input, the
other which uses monochrome imaging. As aforementioned in Section 2.2, we
trained our monochrome U-Net by converting the RGB cutout GZ3D cutouts to
greyscale using Python’s Pillow package. Of course, we note that it is
possible to use imaging from a specific photometric band to train such a
monochrome U-Net, upon which the performance in different bands (for instance,
$g$-band vs. $i$-band) could be examined, however such investigations are
beyond the scope of the current paper. The purpose of this section is to
demonstrate that the U-Net model is not strictly restricted to colour imaging,
but can also be applied to monochrome imaging. For the sake of simplicity, and
to guarantee the correctness of the GZ3D count masks, we have chosen to train
the monochrome U-Net model with greyscale versions of three-band colour
imaging, but this is without loss of generality and does not preclude using
single-band imaging.

Figure 17: The same plots as in Figures 8 and 9, but this time showing the
results for both the RGB colour and monochrome U-Nets.

Figure 15 shows a comparison of the extents of the predicted bar masks from
the RGB colour U-Net and monochrome U-Net for three different local
thresholds. In general, the contours maintain the same overall width and
orientation, but mainly differ in length. At a given threshold, the monochrome
predicted mask seems to extend further out than the corresponding colour mask.
However, there are some cases in which the reverse is true, particularly at
the 80% threshold. It can also be seen at the 80% threshold that the predicted
masks are offset, and so the central coordinates of the predicted bar differ.
We do note that the pixel values for the predicted bar masks are designed to
reflect the confidence the given pixel corresponds to a bar feature. The
discrepancy could thus follow from the fact that one half of the bar is more
easily distinguishable than the other half, shifting the focus of the
predicted mask. This also explains why the high-threshold offset appears to
affect the monochrome U-Net more than the RGB U-Net; after all, the bar
feature is more distinguishable from the rest of the galaxy in a colour image.
On a similar note, it can be seen in Figure 15 that there are some cases where
the 50% threshold monochrome contour stretches out as far as the 20%
threshold. This is especially visible in the spiral galaxies 1408-52822-610
and 1398-53146-619. Also, in the spiral galaxy 1052-52466-209, it can also be
seen that the monochrome contour begins to trace along the spiral arm. This is
likely due of the increased difficulty in differentiating between the end of
the bar and the start of the spiral arm resulting from the loss of colour
information. This is where training on a specific photometric band, such as
the $i$ band where bars are more visually prominent, may be more beneficial.
Taken altogether, the results of Figure 15 nevertheless demonstrate that the
monochrome U-Net is able to successfully extract bars as distinct, separate
features from spiral arms, albeit with a greater degree of uncertainty as
illustrated with the wider contours.

It is useful to compare the predicted lengths $L_{\text{bar}}$ from the
monochrome U-Net with that from the RGB colour U-Net; this is shown in Figure
16, where the points are coloured according to stellar mass, galaxy size, and
morphology. In general, there is a fairly high degree of scatter, but in the
majority of cases the predicted bar length from the monochrome model is
greater than that from the colour model. Figure 16 also appears to show that
the discrepancies are higher for smaller, less massive galaxies where
$L_{\text{bar}}$ (RGB) is itself smaller. Figure 16 also confirms the clear
differences between the NA10 and SAMI samples that was observed in Figures 14,
especially regarding morphology where the smallest SAMI galaxies are almost
all predominantly late spirals, compared to a more even distribution across
morphologies for the NA10 samples. In the case where $L_{\text{bar}}$ (mono)
$>1.5\times L_{\text{bar}}$ (RGB), the majority of samples are spirals. This
is to be expected given the inherent uncertainty in distinguishing the ends of
bars from the starts of spiral arms, as hinted in Figure 15.

Lastly, it is worth inspecting how the use of the monochromatic U-Net alters
the trends in $L_{\text{bar}}$ with respect to physical properties as
previously investigated in Section 3. Figure 17 presents the results of
Figures 8 and 9, this time including the corresponding trends from the
monochrome model. As expected from Figure 16, the lengths from the monochrome
U-Net are generally higher than the corresponding lengths from the colour
U-Net. However, the differences between the two lengths appear to vary with
respect to several properties. Good examples of this are the discrepancies in
both $L_{\text{bar}}$ and $L_{\text{bar}}/R_{d}$ with the NA10 T-Type and
$\lambda_{R_{e}}$. Furthermore, Figure 17 appears to support the
aforementioned greater uncertainty in distinguishing bars and spiral in
monochromatic imaging. In the case of the NA10 dataset, there is a higher
discrepancy for later morphological types compared to early types, with a
similar effect seen with the SAMI galaxies, especially in the higher
discrepancy for high-$\lambda_{R_{e}}$ galaxies which are predominantly
spirals.

###  4.4 Model Benefits and Limitations

Our model developed in this work offers a unique approach to analysing and
studying bars in barred galaxies. However, while this approach has some key
advantages and benefits, there are also some crucial limitations. The major
advantage of our image segmentation approach is that our U-Net directly
outputs spiral and bar masks for a given image of a galaxy without the need
for auxiliary data or free parameters / thresholds that must be given initial
values, such as in isophotal ellipse fitting. Furthermore, the U-Net can make
these predictions extremely quickly, obtaining masks for thousands of galaxies
in a matter of seconds, as previously stated in Section 2. In tandem with our
bar model CNN used to classify barred galaxies from Cavanagh et al. (2022),
this enables our U-Net to be readily applied to study bar lengths in large-
scale observational surveys and even cosmological simulations.

Another benefit is the manner in which the U-Net is configured with respect to
the training data; namely for pixel-level regression rather than pixel-level
classification. The decision for our U-Nets to directly output a smooth,
continuous mask reproducing the GZ3D count masks is mostly intended to
simplify and expand downstream applications. As aforementioned in Section 3,
it is possible to calibrate a suitable local threshold for a given dataset of
barred galaxies based on known bar lengths. This is an important advantage of
our approach; it would not be possible were the U-Net instead pre-trained on
masks with a fixed, pre-determined threshold, for all future applications
would be subject to that hard-coded threshold. The estimated bar lengths are
ultimately dependent on a choice of threshold, however it can be argued that
this is an inevitable necessity to estimate bar lengths, whether from pixel
masks or isophotal ellipse fitting. Since our aim is to reproduce the GZ3D
count masks, we have kept the original count values untouched, having simply
rescaled each pixel value by dividing by the maximum number of volunteers.
However, this does not rule out the use of other nonlinear or weighted scaling
methods to better standardise these counts, such as by minimising the impact
of galaxies with high numbers volunteer counts, or instead using count
fractions to instead formulate the masks as probabilities, in which case the
U-Net could be configured for pixel-level classification with a Softmax
activation. These refinements are a focus of future experimentation, and we
stress that the U-Net models presented in this paper are not restricted to any
one particular method of count mask scaling or preprocessing.

Given that the GZ3D count masks constitute the entirety of the training data
used to train the U-Net, they ultimately impose important fundamental
limitations on our U-Nets. Errors and biases in these masks will necessarily
filter through into the U-Net, and be reflected in the U-Net’s predictions.
This has already been glimpsed in the complexity of the predicted spiral
masks, which is to be expected given the more diverse range of possible spiral
arm arrangements compared to bars. We will discuss the performance of the
model when subject to corrupted count masks in more detail in Appendix A.
Furthermore, as illustrated in Figure 2, the image cutouts provided as part of
the GZ3D data release all feature a purple hexagon, which is less than ideal
from the perspective of pure image segmentation. Fortunately, its presence
does not appear to have any adverse effect on the predicted bar and spiral
masks. We also note that we did not utilise data augmentation techniques when
training the U-Net. Here, data augmentation is a general term referred to
artificially increasing the size of the training data through modifying
existing images, most often by applying affine transformations such as random
rotations, mirroring or scaling, or even cropping and translation. Of course,
any augmentation would have to be applied equally to both the input image
(GZ3D cutout) and the target spiral and bar count masks, which has the
potential to introduce artefacts. As such, to ensure the closest possible
reproduction of the count masks, and for the sake of computational simplicity,
we elected not to utilise data augmentation.

One of the difficulties in detecting bars is poor image quality (Kim et al.,
2016). While our study is limited to nearby galaxies, and therefore does not
probe deep enough to encounter significant resolution limits, low image
quality nevertheless has an impact on the ability of the U-Net to extract
suitably uniform bar masks, ultimately affecting the estimated bar lengths at
a given threshold. This therefore places an upper limit on redshifts at which
our current model can be feasibly applied, keeping in mind other
considerations such as $k$-correction and evolution. Such high-redshift
applications will likely require the use of transfer learning techniques in
order to adapt the current U-Net to account for these differences (see
Domínguez Sánchez et al. 2019; Cavanagh et al. 2023).

One additional application for our U-Net is examining bar evolution in
cosmological simulations, where mock RGB imaging can be readily created at
various snapshots in redshift. Studies have long utilised simulations to study
bars, from the pioneering $N$-body simulations of Hohl (1971); Combes &
Sanders (1981); Pfenniger (1984); Miwa & Noguchi (1998), to more recent
studies examining bars in large-scale hydrodynamical simulations (Algorry et
al., 2017; Zhou et al., 2020; Roshan et al., 2021; Cavanagh et al., 2022;
Rosas-Guevara et al., 2022). Given that our model utilises an image
segmentation approach, it is especially well suited to the finer resolution of
zoom-in simulations, where the physical processes affecting bars can be
studied in greater detail (Martig et al., 2012; Zana et al., 2019). Another
promising application is using the predicted U-Net bar masks not for
estimating bar lengths, but instead as an overlay atop a mass or photometric
flux map in order to estimate the mass fraction of the bar.

##  5 Conclusions

Our main results are summarised below:

  1. (i)

We have developed a deep learning model to perform morphological segmentation
of galaxy imaging in order to estimate the lengths of bars in barred galaxies
and examine how both the absolute bar length $L_{\text{bar}}$ and normalised
bar length $L_{\text{bar}}/R_{d}$ varies with respect to various physical
properties. This represents a novel and inherently versatile approach for
extracting bar masks using solely the image of a galaxy, without any auxiliary
information. We have demonstrated the versatility and efficiency of this new
method through its application to two different datasets with different source
imaging, as well as to both RGB and monochrome imaging. In particular, we
classified known bars from the NA10 morphological catalogue, as well as
predicted barred galaxies from the SAMI catalogue as classified with a CNN
from our previous work.

  2. (ii)

We have found that, in terms of absolute length $L_{\text{bar}}$ bars in high-
mass galaxies are physically longer than in low-mass galaxies. However, this
is not necessarily reflected when examining the normalised bar length. Our
results for the NA10 dataset demonstrated a strong decline in
$L_{\text{bar}}/R_{d}$ with increasing stellar mass, while the SAMI dataset
demonstrated mixed results with a weak overall increase.

  3. (iii)

We have found that bar length also depends strongly on morphology. In general,
bars in early-type galaxies are longer than bars in late-type galaxies. We
have established a similar result when further partitioning the spiral
galaxies, namely that bars in early-type spirals are longer than bars in late-
type spirals.

  4. (iv)

We have found that bars in low spin parameter $\lambda_{R_{e}}$ galaxies are
longer, with respect to their host galaxy, than in galaxies with high spin
parameters. This is likely also reflective of the morphology of the host
galaxy, given that low-$\lambda_{R_{e}}$ galaxies tend to primarily be early
type galaxies (and vice versa).

  5. (v)

We have found that the distribution of bar lengths evolves with redshift. In
the case of the NA10 galaxies, we have found a strong decrease in
$L_{\text{bar}}/R_{d}$ with increasing $z$ with only a modest increase in
$L_{\text{bar}}$. We have also found that the rate of change varies with
morphology, with S0s exhibiting the strongest rate of decline. In the case of
the SAMI galaxies. We note that these trends are likely strongly driven by the
changes in galaxy size and therefore ultimately dependent on sample selection.

  6. (vi)

We have shown that our U-Net model is able to successfully differentiate
between spiral arms and stellar bars in monochromatic imaging. However, we
found that the predicted bar masks in monochromatic imaging tend to be larger
than in colour imaging, subsequently leading to a larger predicted bar length.
This is reflective of the greater uncertainty in establishing the boundary
between stellar bars and spiral arms in the absence of colour. We further note
that $L_{\text{bar}}$ (mono) appears to scale linearly with $L_{\text{bar}}$
(RGB), implying that the two values can be reconciled by applying some scale
factor conversion.

  7. (vii)

We note that our U-Net morphological segmentation technique is inherently
versatile, and it is possible for the model to be applied to a wider range of
observed galaxies. Importantly, our U-Net model can be readily applied to
simulated galaxies, where they can potentially play a crucial role in
analysing bars and subsequently examining the physical processes governing the
formation and growth of bars over cosmic timescales. Apart from just examining
the lengths of bars, the predicted bar masks could also be used to estimate
the mass fractions of bars.

## Acknowledgements

This research was supported by the Australian government through the
Australian Research Council’s Discovery Projects funding scheme (DP220101863).
This study heavily utilised the following Python packages and libraries: numpy
(Harris et al., 2020), matplotlib (Hunter, 2007), seaborn (Waskom, 2021),
Pillow (Van Kemenade et al., 2022), astropy (The Astropy Collaboration et al.,
2013), TensorFlow (Abadi et al., 2016), Keras (Chollet et al., 2015) and
scikit-image (van der Walt et al., 2014).

## Data Availability

This study utilised publicly available data from the NA10, SDSS DR17, Galaxy
Zoo 3D, SAMI DR3 and HSC DR3 datasets (Nair & Abraham, 2010a; Bryant et al.,
2015; Masters et al., 2021; Croom et al., 2021; Abdurro’uf et al., 2022;
Aihara et al., 2022). HSC imaging courtesy of the NAOJ/HSC collaboration.
Specific data pertinent to the paper will be provided upon reasonable request
to the author.

## References

  * Abadi et al. (2016) Abadi M., et al., 2016, TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems (arxiv:1603.04467)
  * Abdurro’uf et al. (2022) Abdurro’uf et al., 2022, ApJSS, 259, 35
  * Abraham et al. (1999) Abraham R. G., Merrifield M. R., Ellis R. S., Tanvir N. R., Brinchmann J., 1999, MNRAS, 308, 569
  * Abraham et al. (2018) Abraham S., Aniyan A. K., Kembhavi A. K., Philip N. S., Vaghmare K., 2018, MNRAS, 477, 894
  * Aguerri et al. (1998) Aguerri J. A. L., Beckman J. E., Prieto M., 1998, AJ, 116, 2136
  * Aguerri et al. (2009) Aguerri J. A. L., Méndez-Abreu J., Corsini E. M., 2009, A&A, 495, 491
  * Aihara et al. (2022) Aihara H., et al., 2022, PASJ, 74, 247
  * Algorry et al. (2017) Algorry D. G., et al., 2017, MNRAS, 469, 1054
  * Alonso et al. (2014) Alonso S., Coldwell G., Lambas D. G., 2014, A&A, 572, A86
  * Athanassoula (2002) Athanassoula E., 2002, ApJ, 569, L83
  * Athanassoula (2003) Athanassoula E., 2003, MNRAS, 341, 1179
  * Athanassoula (2005) Athanassoula E., 2005, Celestial Mechanics and Dynamical Astronomy, 91, 9
  * Athanassoula (2013) Athanassoula E., 2013, in Falcón-Barroso J., Knapen J. H., eds, , Secular Evolution of Galaxies, first edn, Cambridge University Press, pp 305–352, doi:10.1017/CBO9781139547420.006
  * Athanassoula et al. (2013) Athanassoula E., Machado R. E. G., Rodionov S. A., 2013, MNRAS, 429, 1949
  * Baron (2019) Baron D., 2019, Machine Learning in Astronomy: A Practical Overview (arxiv:1904.07248)
  * Bekki (2021) Bekki K., 2021, A&A, 647, A120
  * Bekki & Couch (2011) Bekki K., Couch W. J., 2011, MNRAS, 415, 1783
  * Berentzen et al. (2007) Berentzen I., Shlosman I., Martinez-Valpuesta I., Heller C. H., 2007, ApJ, 666, 189
  * Boucaud et al. (2020) Boucaud A., et al., 2020, MNRAS, 491, 2481
  * Bournaud et al. (2005) Bournaud F., Combes F., Semelin B., 2005, MNRAS:L, 364, L18
  * Brough et al. (2017) Brough S., et al., 2017, ApJ, 844, 59
  * Bryant et al. (2015) Bryant J. J., et al., 2015, MNRAS, 447, 2857
  * Bundy et al. (2015) Bundy K., et al., 2015, ApJ, 798, 7
  * Buta (2013) Buta R. J., 2013, in Oswalt T. D., Keel W. C., eds, , Planets, Stars and Stellar Systems. Springer Netherlands, Dordrecht, pp 1–89, doi:10.1007/978-94-007-5609-0_1
  * Cameron et al. (2010) Cameron E., et al., 2010, MNRAS, 409, 346
  * Cappellari (2016) Cappellari M., 2016, ARA&A, 54, 597
  * Cavanagh & Bekki (2020) Cavanagh M. K., Bekki K., 2020, A&A, 641, A77
  * Cavanagh et al. (2021) Cavanagh M. K., Bekki K., Groves B. A., 2021, MNRAS, 506, 659
  * Cavanagh et al. (2022) Cavanagh M. K., Bekki K., Groves B. A., Pfeffer J., 2022, MNRAS, 510, 5164
  * Cavanagh et al. (2023) Cavanagh M. K., Bekki K., Groves B. A., 2023, MNRAS, 520, 5885
  * Cervantes Sodi (2017) Cervantes Sodi B., 2017, ApJ, 835, 80
  * Cervantes-Sodi et al. (2013) Cervantes-Sodi B., Li C., Park C., Wang L., 2013, ApJ, 775, 19
  * Cheung et al. (2013) Cheung E., et al., 2013, ApJ, 779, 162
  * Chollet (2021) Chollet F., 2021, Deep Learning with Python, second edn. Manning Publications, Shelter Island
  * Chollet et al. (2015) Chollet F., et al., 2015, Keras, https://keras.io
  * Coccato et al. (2022) Coccato L., Fraser-McKelvie A., Jaffé Y. L., Johnston E. J., Cortesi A., Pallero D., 2022, MNRAS, 515, 201
  * Combes & Elmegreen (1993) Combes F., Elmegreen B. G., 1993, Astronomy and Astrophysics, 271, 391
  * Combes & Sanders (1981) Combes F., Sanders R. H., 1981, Astronomy and Astrophysics, 96, 164
  * Conselice (2014) Conselice C. J., 2014, ARA&A, 52, 291
  * Consolandi (2016) Consolandi G., 2016, A&A, 595, A67
  * Cortese et al. (2016) Cortese L., et al., 2016, MNRAS, 463, 170
  * Croom et al. (2012) Croom S. M., et al., 2012, MNRAS, 421, 872
  * Croom et al. (2021) Croom S. M., et al., 2021, MNRAS, 505, 991
  * Deeley et al. (2020) Deeley S., et al., 2020, MNRAS, 498, 2372
  * Díaz-García et al. (2016) Díaz-García S., Salo H., Laurikainen E., Herrera-Endoqui M., 2016, Astronomy and Astrophysics, 587, A160
  * Domínguez Sánchez et al. (2019) Domínguez Sánchez H., et al., 2019, MNRAS, 484, 93
  * Driver et al. (2011) Driver S. P., et al., 2011, MNRAS, 413, 971
  * Durbala et al. (2008) Durbala A., Sulentic J. W., Buta R., Verdes-Montenegro L., 2008, MNRAS, 390, 881
  * Durbala et al. (2009) Durbala A., Buta R., Sulentic J. W., Verdes-Montenegro L., 2009, MNRAS, 397, 1756
  * Ellison et al. (2011) Ellison S. L., Nair P., Patton D. R., Scudder J. M., Mendel J. T., Simard L., 2011, MNRAS, 416, 2182
  * Elmegreen & Elmegreen (1985) Elmegreen B. G., Elmegreen D. M., 1985, ApJ, 288, 438
  * Elmegreen et al. (1990) Elmegreen D. M., Bellin A. D., Elmegreen B. G., 1990, ApJ, 364, 415
  * Emsellem et al. (2007) Emsellem E., et al., 2007, MNRAS, 379, 401
  * Emsellem et al. (2011) Emsellem E., et al., 2011, MNRAS, 414, 888
  * Erwin (2005) Erwin P., 2005, MNRAS, 364, 283
  * Erwin (2018) Erwin P., 2018, MNRAS, 474, 5372
  * Erwin (2019) Erwin P., 2019, MNRAS, 489, 3553
  * Eskridge et al. (2000) Eskridge P. B., et al., 2000, AJ, 119, 536
  * Fanali et al. (2015) Fanali R., Dotti M., Fiacconi D., Haardt F., 2015, MNRAS, 454, 3641
  * Fluke & Jacobs (2020) Fluke C. J., Jacobs C., 2020, WIREs Data Mining and Knowledge Discovery, 10, e1349
  * Fraser-McKelvie et al. (2020a) Fraser-McKelvie A., et al., 2020a, MNRAS, 495, 4158
  * Fraser-McKelvie et al. (2020b) Fraser-McKelvie A., et al., 2020b, MNRAS, 499, 1116
  * Gadotti (2008) Gadotti D. A., 2008, MNRAS, 384, 420
  * Gadotti & de Souza (2006) Gadotti D. A., de Souza R. E., 2006, ApJSS, 163, 270
  * Garcia-Gómez et al. (2017) Garcia-Gómez C., Athanassoula E., Barberà C., Bosma A., 2017, A&A, 601, A132
  * Géron et al. (2021) Géron T., Smethurst R. J., Lintott C., Kruk S., Masters K. L., Simmons B., Stark D. V., 2021, MNRAS, 507, 4389
  * Goodfellow et al. (2016) Goodfellow I., Bengio Y., Courville A., 2016, Deep Learning. MIT Press
  * Graham et al. (2005) Graham A. W., Driver S. P., Petrosian V., Conselice C. J., Bershady M. A., Crawford S. M., Goto T., 2005, AJ, 130, 1535
  * Graham et al. (2018) Graham M. T., et al., 2018, MNRAS, 477, 4711
  * Guo et al. (2019) Guo R., Mao S., Athanassoula E., Li H., Ge J., Long R. J., Merrifield M., Masters K., 2019, MNRAS, 482, 1733
  * Harris et al. (2020) Harris C. R., et al., 2020, Nature, 585, 357
  * Hausen & Robertson (2020) Hausen R., Robertson B. E., 2020, ApJSS, 248, 20
  * He et al. (2015) He K., Zhang X., Ren S., Sun J., 2015, Deep Residual Learning for Image Recognition (arxiv:1512.03385)
  * Hohl (1971) Hohl F., 1971, ApJ, 168, 343
  * Hoyle et al. (2011) Hoyle B., et al., 2011, MNRAS, 415, 3627
  * Huertas-Company & Lanusse (2023) Huertas-Company M., Lanusse F., 2023, PASA, 40, e001
  * Hunter (2007) Hunter J. D., 2007, Computing in Science & Engineering, 9, 90
  * Jin et al. (2016) Jin J., Dundar A., Culurciello E., 2016, Robust Convolutional Neural Networks under Adversarial Noise (arxiv:1511.06306)
  * Jogee et al. (2005) Jogee S., Scoville N., Kenney J. D. P., 2005, ApJ, 630, 837
  * Kim et al. (2016) Kim T., Gadotti D. A., Athanassoula E., Bosma A., Sheth K., Lee M. G., 2016, MNRAS, 462, 3430
  * Kim et al. (2021) Kim T., Athanassoula E., Sheth K., Bosma A., Park M.-G., Lee Y. H., Ann H. B., 2021, ApJ, 922, 196
  * Kormendy (1979) Kormendy J., 1979, ApJ, 227, 714
  * Kormendy & Kennicutt (2004) Kormendy J., Kennicutt R. C., 2004, ARA&A, 42, 603
  * Kruk et al. (2018) Kruk S. J., et al., 2018, MNRAS, 473, 4731
  * Laine et al. (2002) Laine S., Shlosman I., Knapen J. H., Peletier R. F., 2002, ApJ, 567, 97
  * Laurikainen et al. (2009) Laurikainen E., Salo H., Buta R., Knapen J. H., 2009, ApJ, 692, L34
  * LeCun et al. (2015) LeCun Y., Bengio Y., Hinton G., 2015, Nature, 521, 436
  * Lee et al. (2012) Lee G.-H., Park C., Lee M. G., Choi Y.-Y., 2012, ApJ, 745, 125
  * Lin et al. (2020) Lin L., et al., 2020, MNRAS, 499, 1406
  * Marinova & Jogee (2007) Marinova I., Jogee S., 2007, ApJ, 659, 1176
  * Marinova et al. (2009) Marinova I., Jogee S., Barazza F. D., Heiderman A., Gray M. E., Barden M., 2009, in Jogee S., Marinova I., Hao L., Blanc G. A., eds, Astronomical Society of the Pacific Conference Series, Vol. 419, Galaxy Evolution: Emerging Insights and Future Challenges. Astronomical Society of the Pacific, p. 138
  * Martig et al. (2012) Martig M., Kraljic K., Bournaud F., 2012, Proceedings of the International Astronomical Union, 10, 373
  * Masters et al. (2011) Masters K. L., et al., 2011, MNRAS, 411, 2026
  * Masters et al. (2012) Masters K. L., et al., 2012, MNRAS, 424, 2180
  * Masters et al. (2021) Masters K. L., et al., 2021, MNRAS, 507, 3923
  * Melvin et al. (2014) Melvin T., et al., 2014, MNRAS, 438, 2882
  * Menendez-Delmestre et al. (2007) Menendez-Delmestre K., Sheth K., Schinnerer E., Jarrett T. H., Scoville N. Z., 2007, ApJ, 657, 790
  * Minaee et al. (2020) Minaee S., Boykov Y., Porikli F., Plaza A., Kehtarnavaz N., Terzopoulos D., 2020, Image Segmentation Using Deep Learning: A Survey (arxiv:2001.05566)
  * Miwa & Noguchi (1998) Miwa T., Noguchi M., 1998, ApJ, 499, 149
  * Moran et al. (2007) Moran S. M., Loh B. L., Ellis R. S., Treu T., Bundy K., MacArthur L. A., 2007, ApJ, 665, 1067
  * Nair & Abraham (2010a) Nair P. B., Abraham R. G., 2010a, ApJSS, 186, 427
  * Nair & Abraham (2010b) Nair P. B., Abraham R. G., 2010b, ApJ, 714, L260
  * Odewahn (2004) Odewahn S. C., 2004, in Block D. L., Puerari I., Freeman K. C., Groess R., Block E. K., eds, , Vol. 319, Penetrating Bars through Masks of Cosmic Dust. Springer Netherlands, Dordrecht, pp 453–458, doi:10.1007/978-1-4020-2862-5_41
  * Ohta et al. (1990) Ohta K., Hamabe M., Wakamatsu K.-I., 1990, ApJ, 357, 71
  * Peebles (1971) Peebles P. J. E., 1971, Astronomy and Astrophysics, 11, 377
  * Pfenniger (1984) Pfenniger D., 1984, Astronomy and Astrophysics, 134, 373
  * Rautiainen et al. (2002) Rautiainen P., Salo H., Laurikainen E., 2002, MNRAS, 337, 1233
  * Rawlings et al. (2020) Rawlings A., et al., 2020, MNRAS, 491, 324
  * Reese et al. (2007) Reese A. S., Williams T. B., Sellwood J. A., Barnes E. I., Powell B. A., 2007, AJ, 133, 2846
  * Rizzo et al. (2018) Rizzo F., Fraternali F., Iorio G., 2018, MNRAS, 476, 2137
  * Robertson et al. (2022) Robertson B. E., et al., 2022, Morpheus Reveals Distant Disk Galaxy Morphologies with JWST: The First AI/ML Analysis of JWST Images (arxiv:2208.11456)
  * Ronneberger et al. (2015) Ronneberger O., Fischer P., Brox T., 2015, U-Net: Convolutional Networks for Biomedical Image Segmentation (arxiv:1505.04597)
  * Rosas-Guevara et al. (2019) Rosas-Guevara Y., et al., 2019, MNRAS, p. stz3180
  * Rosas-Guevara et al. (2022) Rosas-Guevara Y., et al., 2022, MNRAS, 512, 5339
  * Roshan et al. (2021) Roshan M., Ghafourian N., Kashfi T., Banik I., Haslbauer M., Cuomo V., Famaey B., Kroupa P., 2021, MNRAS, 508, 926
  * Saha & Elmegreen (2018) Saha K., Elmegreen B., 2018, ApJ, 858, 24
  * Sellwood & Wilkinson (1993) Sellwood J. A., Wilkinson A., 1993, Reports on Progress in Physics, 56, 173
  * Sheth et al. (2008) Sheth K., et al., 2008, ApJ, 675, 1141
  * Shlosman & Noguchi (1993) Shlosman I., Noguchi M., 1993, ApJ, 414, 474
  * Shlosman et al. (1989) Shlosman I., Frank J., Begelman M. C., 1989, Nature, 338, 45
  * Skibba et al. (2012) Skibba R. A., et al., 2012, MNRAS, 423, 1485
  * Spinoso et al. (2017) Spinoso D., Bonoli S., Dotti M., Mayer L., Madau P., Bellovary J., 2017, MNRAS, 465, 3729
  * Sureau et al. (2020) Sureau F., Lechat A., Starck J.-L., 2020, A&A, 641, A67
  * Tawfeek et al. (2022) Tawfeek A. A., et al., 2022, ApJ, 940, 1
  * The Astropy Collaboration et al. (2013) The Astropy Collaboration et al., 2013, A&A, 558, A33
  * Valenzuela & Klypin (2003) Valenzuela O., Klypin A., 2003, MNRAS, 345, 406
  * Van Kemenade et al. (2022) Van Kemenade H., et al., 2022, Python-Pillow/Pillow: 9.2.0, Zenodo, doi:10.5281/ZENODO.6788304
  * Vera et al. (2016) Vera M., Alonso S., Coldwell G., 2016, A&A, 595, A63
  * Vojtekova et al. (2021) Vojtekova A., Lieu M., Valtchanov I., Altieri B., Old L., Chen Q., Hroch F., 2021, MNRAS, 503, 3204
  * Wake et al. (2017) Wake D. A., et al., 2017, AJ, 154, 86
  * Waskom (2021) Waskom M., 2021, Journal of Open Source Software, 6, 3021
  * Weinberg (1985) Weinberg M. D., 1985, MNRAS, 213, 451
  * Weinzirl et al. (2009) Weinzirl T., Jogee S., Khochfar S., Burkert A., Kormendy J., 2009, ApJ, 696, 411
  * Zana et al. (2019) Zana T., Capelo P. R., Dotti M., Mayer L., Lupi A., Haardt F., Bonoli S., Shen S., 2019, MNRAS, 488, 1864
  * Zhou et al. (2020) Zhou Z.-B., Zhu W., Wang Y., Feng L.-L., 2020, ApJ, 895, 92
  * van de Sande et al. (2021) van de Sande J., et al., 2021, MNRAS, 505, 3078
  * van der Walt et al. (2014) van der Walt S., Schönberger J. L., Nunez-Iglesias J., Boulogne F., Warner J. D., Yager N., Gouillart E., Yu T., 2014, PeerJ, 2, e453

##  Appendix A Model Performance on Corrupted Inputs

Figure 18: Example application of the U-Net to six randomly selected galaxies
from the GZ3D test set with corrupt or missing masks. As with Figure 2, each
row shows the input GZ3D colour cutout, the volunteer-drawn GZ3D spiral and
bar masks, and the subsequent predicted spiral and bar masks as directly
outputted by the U-Net. The image cutouts are annotated with their GZ3D ID in
the top-left.

The GZ3D dataset (Masters et al., 2021). Apart from the selection criteria
discussed in Section 2, namely the selection of galaxies with spiral or bar
masks that have been annotated by at least three volunteers, there is no
further filtering or cleaning of the training masks. It is important to note
that the publicly available GZ3D masks have not been cleaned or otherwise
assessed for quality, and there are invariably unrealistic or otherwise
corrupted masks present throughout the full data release. Despite applying the
minimum volunteer annotation threshold, the training data for our U-Nets
likewise includes these corrupted masks. While this does impact the
performance of the model, it may actually be beneficial for improving the
robustness and reliability of the model. Deliberately corrupting inputs is a
known technique in deep learning, used for instance to improve model
regularisation and prevent overfitting (Jin et al., 2016). These corrupted
masks are therefore useful for assessing the overall performance and
generalisability of the U-Net.

Figure 18 shows a selection of galaxies from our test set that feature
corrupted, missing or otherwise non-ideal GZ3D spiral and bar masks. Despite
these anomalous masks, the predicted masks obtained from the U-Net are
somewhat sensible, in some cases able to recover or fill-in features that were
missing from the GZ3D masks. Examples 101750, 42158 and 484088 show spiral
galaxies that have no annotated GZ3D spiral masks. Despite this, the U-Net
predicts spiral regions for each of these images. We note that, for these
specific examples, the difference between the GZ3D and predicted masks does
increase validation loss of the model. This is undesirable from the point of
view of the model training, yet the actual outcome is desirable in that the
model has filled in the missing spiral masks. Similarly, the galaxy 42158 is
unbarred despite being indicated as such in the GZ3D bar mask. The U-Net does
not extract a clear bar region, which is indeed desirable since there is no
physically-present bar for it to extract. Another noteworthy example is galaxy
61557, which features an erroneous GZ3D bar mask, with some classifiers
incorrectly tracing the spiral arm. In this case the U-Net manages to ignore
the spiral and correctly output a physically sensible bar mask. When it comes
to maximising performance, our U-Net could benefit from greater quality
control with regard to the GZ3D training data. This is a focus of future work.