<blockquote>
  <p>Is there any standard software or algorithm for computing the Sérsic index from an image?</p>
</blockquote>

<p>I don't think it is standard but <a href="http://arxiv.org/pdf/1307.4996v1.pdf" rel="noreferrer">Vika et al (2013)</a> have used a modified version of GALFIT to extract Sérsic profiles. EDIT> But I see you already found it ;-)</p>

<blockquote>
  <p>Are there reference images I can work from that would let me check if my algorithm is reasonable?</p>
</blockquote>

<p>There are references in literature that provide images with Sérsic profiles, but I haven't been able to find a database which I think is what you are looking for.</p>

<blockquote>
  <p>Any recommendations on how to proceed would be welcome.</p>
</blockquote>

<p>For your purposes it is not really necessary to calculate the Sérsic index so that you can compare it with literature. If your Sérsic index, which is just one feature for your classification algorithm, is distinctive enough to be able to distinguish between different morphological classes than that is fine.</p>

<p>I imagine that it might be difficult to calculate reliable Sérsic indices from the images provided by GalaxyZoo. The images I remember are often low resolution images of galaxies. </p>

<p>So I would proceed by calculating your Sérsic index for your training and test sets and see how well this feature performs in a classification task.</p>

CC BY-SA 3.0
2014-01-25T11:30:42.663Z
My estimates of the Sersic profile perform poorly as predictors of galaixy morphology, which is curious since this paper http://articles.adsabs.harvard.edu/cgi-bin/nph-iarticle_query?2008IAUS..245...59V&amp;data_type=PDF_HIGH&amp;whole_paper=YES&amp;type=PRINTER&amp;filetype=.pdf suggests Sersic index is very good at distinguishing between early types and late types. Yes the images are rather low resolution. I'll see what I can get out of GALFIT.
James King
CC BY-SA 3.0
2014-01-25T11:17:40.203Z
2014-01-25T11:17:40.203Z
Dieudonné
<p>I suspect the main problem is that the JPEG images you're working with are <em>already</em> log-scaled (or scaled via some other function such as a square root). Since the centers of most galaxies are orders of magnitude brighter in linear terms than the outer regions, a JPEG image (which, remember, has only 8 bits per color channel, and so can only represent 256 levels of brightness per channel) representing linear brightness would show a bright center and nothing outside. So your fit is effectively something like</p>

<pre><code>log(log(log(I))) ~ log(R)
</code></pre>

<p>Programs like <code>GALFIT</code> and <code>GIM2D</code> (or my own <code>Imfit</code> code) are meant to fit 2D grayscale, floating-point images with linear intensities which are in the FITS astronomical image format. (<code>GIM2D</code> also requires the <code>IRAF</code> software system in order to run.) They won't work with JPEG images.</p>

CC BY-SA 3.0
2015-06-05T11:45:33.177Z
2015-06-05T11:45:33.177Z
Peter Erwin
<p>I am trying to calculate the Sérsic profile of various galaxies from the SDSS based on the images provided by the galaxy zoo site. I am doing this as part of a <a href="http://www.kaggle.com/c/galaxy-zoo-the-galaxy-challenge/leaderboard" rel="noreferrer">kaggle competition</a> on using machine learning to predict galaxy morphology. I have no chance of a high rank in this competition so I'm not hesitant to ask for help.</p>

<p>I used the R contourLines function to identify the isophotes of the galaxy and then fit ellipses to each isophote. This seemed to work well, the isophotes are almost always well fit by the ellipses and the ellipses are nearly concentric. Then letting <code>I</code> be the pixel intensity of an isophote and <code>R</code> be the length of the semi-major axis of the corresponding ellipse, I need to fit an equation of the form</p>

<pre><code>log I(R) = log I_0 - k * R^(1/n)
</code></pre>

<p>The simple approach seemed to be to take the log of both sides and use OLS regression, so I fit a linear model in R of the form</p>

<pre><code>log(log(I)) ~ log(R)
</code></pre>

<p>The resulting graphs showed a good fit but the resulting Sérsic indices n are almost always less than one and never as big as two. This doesn't seem right since indices of 4 or higher seem common in my reading. I don't get anywhere near 4 for an image of M87.</p>

<p>Possibly taking log log flattens things out too much and the index is not responsive enough. I tried using nls to work with just the log but it didn't move the indices much.</p>

<p>Is there any standard software or algorithm for computing the Sérsic index from an image? Are there reference images I can work from that would let me check if my algorithm is reasonable? Any recommendations on how to proceed would be welcome.</p>

<p>UPDATE: I have found the programs GALFIT and GIM2D which look like they might be useful. Any other software that is commonly used for this?</p>

CC BY-SA 3.0
2014-01-25T10:09:17.147Z
Just to be sure; you are using the natural logarithm on I and not base 10?
Dieudonné
CC BY-SA 3.0
2014-01-25T10:11:06.250Z
Yes, natural log.
James King
CC BY-SA 3.0
2014-01-27T21:18:29.200Z
So, from what I've discussed with a colleague, a Sersic index of 4 is called a de Vaucouleurs profile, which best describes large elliptical galaxies. A Sersic index of 1 is an exponential profile, which best fits spiral galaxies. I don't know how many you have fit so far, but you may not need to panic about having Sersic indices of 1. It would be helpful to see a plot of your "reconstructed" indices.
astromax
CC BY-SA 3.0
2014-01-28T02:10:12.610Z
thanks I'll get a plot in the next day or so. I'm also planning to try out galfit, just need to find the time.
James King
<galaxy>
Computing the Sérsic profile of a galaxy from jpg images
James King
# Computing the Sérsic profile of a galaxy from jpg images

(Asked by: username_0 on 2014-01-25)

I am trying to calculate the Sérsic profile of various galaxies from the SDSS based on the images provided by the galaxy zoo site. I am doing this as part of a kaggle competition on using machine learning to predict galaxy morphology. I have no chance of a high rank in this competition so I'm not hesitant to ask for help.
I used the R contourLines function to identify the isophotes of the galaxy and then fit ellipses to each isophote. This seemed to work well, the isophotes are almost always well fit by the ellipses and the ellipses are nearly concentric. Then letting I be the pixel intensity of an isophote and R be the length of the semi-major axis of the corresponding ellipse, I need to fit an equation of the form
log I(R) = log I_0 - k * R^(1/n)

The simple approach seemed to be to take the log of both sides and use OLS regression, so I fit a linear model in R of the form
log(log(I)) ~ log(R)

The resulting graphs showed a good fit but the resulting Sérsic indices n are almost always less than one and never as big as two. This doesn't seem right since indices of 4 or higher seem common in my reading. I don't get anywhere near 4 for an image of M87.
Possibly taking log log flattens things out too much and the index is not responsive enough. I tried using nls to work with just the log but it didn't move the indices much.
Is there any standard software or algorithm for computing the Sérsic index from an image? Are there reference images I can work from that would let me check if my algorithm is reasonable? Any recommendations on how to proceed would be welcome.
UPDATE: I have found the programs GALFIT and GIM2D which look like they might be useful. Any other software that is commonly used for this?

**Tags:** galaxy
> **Comments:**
> **username_1**: Just to be sure; you are using the natural logarithm on I and not base 10?  
> **username_0**: Yes, natural log.  
> **username_2**: So, from what I've discussed with a colleague, a Sersic index of 4 is called a de Vaucouleurs profile, which best describes large elliptical galaxies. A Sersic index of 1 is an exponential profile, which best fits spiral galaxies. I don't know how many you have fit so far, but you may not need to panic about having Sersic indices of 1. It would be helpful to see a plot of your "reconstructed" indices.  
> **username_0**: thanks I'll get a plot in the next day or so. I'm also planning to try out galfit, just need to find the time.  

---

## 2 answers

### Answer by username_1 on 2014-01-25. Score: 5

> Is there any standard software or algorithm for computing the Sérsic index from an image?

I don't think it is standard but [Vika et al (2013)](http://arxiv.org/pdf/1307.4996v1.pdf) have used a modified version of GALFIT to extract Sérsic profiles. EDIT> But I see you already found it ;-)

> Are there reference images I can work from that would let me check if my algorithm is reasonable?

There are references in literature that provide images with Sérsic profiles, but I haven't been able to find a database which I think is what you are looking for.

> Any recommendations on how to proceed would be welcome.

For your purposes it is not really necessary to calculate the Sérsic index so that you can compare it with literature. If your Sérsic index, which is just one feature for your classification algorithm, is distinctive enough to be able to distinguish between different morphological classes than that is fine.

I imagine that it might be difficult to calculate reliable Sérsic indices from the images provided by GalaxyZoo. The images I remember are often low resolution images of galaxies.

So I would proceed by calculating your Sérsic index for your training and test sets and see how well this feature performs in a classification task.

> **Comments:**
> **username_0**: My estimates of the Sersic profile perform poorly as predictors of galaixy morphology, which is curious since this paper http://articles.adsabs.harvard.edu/cgi-bin/nph-iarticle_query?2008IAUS..245...59V&amp;data_type=PDF_HIGH&amp;whole_paper=YES&amp;type=PRINTER&amp;filetype=.pdf suggests Sersic index is very good at distinguishing between early types and late types. Yes the images are rather low resolution. I'll see what I can get out of GALFIT.  

---

### Answer by username_3 on 2015-06-05. Score: 4

I suspect the main problem is that the JPEG images you're working with are already log-scaled (or scaled via some other function such as a square root). Since the centers of most galaxies are orders of magnitude brighter in linear terms than the outer regions, a JPEG image (which, remember, has only 8 bits per color channel, and so can only represent 256 levels of brightness per channel) representing linear brightness would show a bright center and nothing outside. So your fit is effectively something like
log(log(log(I))) ~ log(R)

Programs like GALFIT and GIM2D (or my own Imfit code) are meant to fit 2D grayscale, floating-point images with linear intensities which are in the FITS astronomical image format. (GIM2D also requires the IRAF software system in order to run.) They won't work with JPEG images.


---

