# Computing the Sérsic profile of a galaxy from jpg images

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?

• Just to be sure; you are using the natural logarithm on I and not base 10? – Dieudonné Jan 25 '14 at 10:09
• Yes, natural log. – James King Jan 25 '14 at 10:11
• 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 Jan 27 '14 at 21:18
• 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 Jan 28 '14 at 2:10

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) 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.

• My estimates of the Sersic profile perform poorly as predictors of galaixy morphology, which is curious since this paper articles.adsabs.harvard.edu/cgi-bin/… 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 Jan 25 '14 at 11:30

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.