<p>I have a large quantity of old digital images of low energy electron diffraction (<a href="https://en.wikipedia.org/wiki/Low-energy_electron_diffraction" rel="nofollow noreferrer">LEED</a>) patterns that I must process to identify and locate small, sometimes elongated gaussian-like blobs of a few pixels in width within a noisy and artifact-riddled background.</p>
<p>I'm currently reading up on Laplacian of Gaussian blob detection <a href="https://projectsflix.com/opencv/laplacian-blob-detector-using-python/" rel="nofollow noreferrer">1</a>, <a href="https://en.wikipedia.org/wiki/Blob_detection#The_Laplacian_of_Gaussian" rel="nofollow noreferrer">2</a>, <a href="https://stackoverflow.com/q/51411156/3904031">3</a> and have started to implement the &quot;roll-your-own&quot; script in the first link; there are python packages like OpenCV and Scikit-image that have standard libraries for this as well and I believe they both have Laplacian of Gaussian blob detection, but I like to do it first myself to better understand what's going on.</p>
<h2>Why are you asking this here in Astronomy SE?</h2>
<p>Good question! Because this looks at least superficially a lot like what astronomers need to do when searching for objects in deep space imaging applications, and there may be some standard implementations in AstroPy or even lecture notes for Digital Imaging in Astronomy 101 courses.</p>
<p>In parallel with my brute force efforts, how might I compliment this work with existing astronomical imaging techniques to compare notes? It would be great if it turned out that some existing script or package searching for distant elliptical galaxies or <a href="https://en.wikipedia.org/wiki/Weak_gravitational_lensing#Methodology" rel="nofollow noreferrer">weak gravitational lensing</a> could be applied directly to these kinds of images!</p>
<p>Example image (most data has <s>smaller pixels</s> higher pixel density, but I need to process these low pixel count images as well):</p>
<p><a href="https://i.sstatic.net/a2DP6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/a2DP6.png" alt="enter image description here" /></a></p>
<p>The kinds of &quot;spots&quot; I'm looking for:</p>
<p><a href="https://i.sstatic.net/uDvkE.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uDvkE.png" alt="enter image description here" /></a></p>
<p>First try with Python implementation of <a href="https://projectsflix.com/opencv/laplacian-blob-detector-using-python/" rel="nofollow noreferrer">Laplacian of Gaussian blob detection</a>, haven't yet looked at generalizing to non-circular shapes, just ran the script in the link with a few small modifications.</p>
<p><a href="https://i.sstatic.net/7OjGA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7OjGA.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2020-01-09T08:45:41.633Z
If the artifacts are the same in all the images, and the spots you are trying to find are not, you could start by stacking all the images and taking the median at each pixel. Then you substract this from each image in order to remove some of the structures you don't want
usernumber
CC BY-SA 4.0
2020-01-09T09:08:37.887Z
@usernumber Thanks, that's a good idea! Unfortunately they are not. :-(
uhoh
CC BY-SA 4.0
2020-01-09T19:14:00.247Z
Have you worked with ImageJ?  https://imagej.nih.gov/ij/   It has some tools to do blob detection and similar stuff, developed at least partly with astronomers in mind.
Carl Witthoft
CC BY-SA 4.0
2020-01-09T20:00:19.363Z
@CarlWitthoft I've used it to make GIFs but haven't explored it otherwise. I'll try that today and see what happens. Ultimately I'm looking for a Python solution so I can integrate it into a workflow and also so I can *get under the hood* and modify and optimize it, but this could be a helpful stepping-stone.
uhoh
CC BY-SA 4.0
2020-01-10T19:02:42.003Z
The software that's most used for detecting things in astronomical images is [SExtractor](https://www.astromatic.net/software/sextractor) or the Python library [SEP](https://sep.readthedocs.io/en/v1.0.x/) which implements the same core algorithms.
astrosnapper
CC BY-SA 4.0
2020-01-11T05:56:09.583Z
@astrosnapper thank you, I'll have a look today. Hopefully I can find something that doesn't have a big learning curve and/or require FITS or some special format that I'll also have to construct, but if so, maybe it will be fun to learn!
uhoh
CC BY-SA 4.0
2020-09-18T04:33:41.457Z
@astrosnapper I've added a bounty to get a little more detail. These days I'm doing [this kind of thing](https://math.stackexchange.com/a/3829536/284619) so work on image processing is slow, but I've got to do it and I need something to compare to.
uhoh
CC BY-SA 4.0
2020-09-20T11:10:26.833Z
@student I'll take a look, thanks! There is symmetry in the underlying math, but there are distortions and tilts and some "stars" will disappear at times, so it's probably necessary to treat the spots as unrelated at this step .Why would SExtractor benefit from or need symmetry?
uhoh
CC BY-SA 4.0
2020-09-20T11:26:21.993Z
@student oh I see. Strictly periodic surface layers will each have 2, 3, 4, or 6-fold symmetry and it's okay to anticipate that, but these diffraction spots move around a lot and appear/disappear; that's basically what the experiment tries to make happen. Okay I will check it out for sure, thanks! btw does it only run on linux OS?
uhoh
CC BY-SA 4.0
2020-09-20T13:50:45.017Z
@student I am on macOS but I have no developer skills whatsoever. All I can do pip install X where X is some python package. I tried [this once](https://apple.stackexchange.com/q/327177/143729) got it installed, but didn't know what I was doing.
uhoh
CC BY-SA 4.0
2020-09-20T14:18:52.213Z
@student oh, how easy! Okay, installed and running, but now I will have to read up on how to write the job files (configuration and measurement) to go along with the image. If you write up a short answer with something basic based on the first image in the question just to get me started, I can accept right away. Either way, thank you very much!
uhoh
CC BY-SA 4.0
2020-09-20T14:19:39.077Z
btw I used `conda install -c conda-forge astromatic-source-extractor` from [here](https://anaconda.org/conda-forge/astromatic-source-extractor) which has an extra `-c` compared to your line, I hope it won't blow up.
uhoh
CC BY-SA 4.0
2020-09-20T14:33:20.277Z
Despite all the explanation, I think this question is off-topic here and on-topic and better answered in stackoverflow with the tag [image-processing]. That's true even more so as object detection of small particles or similar depends VERY HEAVILY on their excact properties and what is common about the objects, about the properties of the background and how you can treat reduction by that. PIV and particle recognition / shadowgraphy is a own subject in image-processing and analysis
planetmaker
CC BY-SA 4.0
2020-09-20T14:51:00.753Z
@planetmaker That is a good point, and now armed with my own poor implementation and this package, I can write a better, more detailed question and post it there perhaps. I'm bootstrapping my way up here. This way nobody will ask "What have you tried so far?" or "Why not ask in Astronomy SE?" SO is much better than it used to be, but there are random, drive-by downers that can kill a question if you don't write it correctly. I've asked about 3,000 SE/SO questions now; I've found the bootstrap method works well and produces helpful and well-received answers most of the time.
uhoh
CC BY-SA 4.0
2020-09-22T17:22:17.017Z
@student the bounty expires in 2 days, then there's a 24 hour silent grace period. After that the points disappear into a black hole, and since reputation has no charge nor spin, they're truly lost. Consider writing a short answer?
uhoh
<observational-astronomy><python><mathematics><sky-survey><image-processing>
How are small objects automatically identified and their locations determined in digital images?
uhoh
# How are small objects automatically identified and their locations determined in digital images?

(Asked by: username_0 on 2020-01-09)

I have a large quantity of old digital images of low energy electron diffraction ([LEED](https://en.wikipedia.org/wiki/Low-energy_electron_diffraction)) patterns that I must process to identify and locate small, sometimes elongated gaussian-like blobs of a few pixels in width within a noisy and artifact-riddled background.

I'm currently reading up on Laplacian of Gaussian blob detection [1](https://projectsflix.com/opencv/laplacian-blob-detector-using-python/), [2](https://en.wikipedia.org/wiki/Blob_detection#The_Laplacian_of_Gaussian), [3](https://stackoverflow.com/q/51411156/3904031) and have started to implement the "roll-your-own" script in the first link; there are python packages like OpenCV and Scikit-image that have standard libraries for this as well and I believe they both have Laplacian of Gaussian blob detection, but I like to do it first myself to better understand what's going on.

## Why are you asking this here in Astronomy SE?

Good question! Because this looks at least superficially a lot like what astronomers need to do when searching for objects in deep space imaging applications, and there may be some standard implementations in AstroPy or even lecture notes for Digital Imaging in Astronomy 101 courses.

In parallel with my brute force efforts, how might I compliment this work with existing astronomical imaging techniques to compare notes? It would be great if it turned out that some existing script or package searching for distant elliptical galaxies or [weak gravitational lensing](https://en.wikipedia.org/wiki/Weak_gravitational_lensing#Methodology) could be applied directly to these kinds of images!

Example image (most data has ~~smaller pixels~~ higher pixel density, but I need to process these low pixel count images as well):

[![enter image description here](https://i.sstatic.net/a2DP6.png)](https://i.sstatic.net/a2DP6.png)

The kinds of "spots" I'm looking for:

[![enter image description here](https://i.sstatic.net/uDvkE.png)](https://i.sstatic.net/uDvkE.png)

First try with Python implementation of [Laplacian of Gaussian blob detection](https://projectsflix.com/opencv/laplacian-blob-detector-using-python/), haven't yet looked at generalizing to non-circular shapes, just ran the script in the link with a few small modifications.

[![enter image description here](https://i.sstatic.net/7OjGA.png)](https://i.sstatic.net/7OjGA.png)

**Tags:** observational-astronomy, python, mathematics, sky-survey, image-processing
> **Comments:**
> **username_1**: If the artifacts are the same in all the images, and the spots you are trying to find are not, you could start by stacking all the images and taking the median at each pixel. Then you substract this from each image in order to remove some of the structures you don't want  
> **username_0**: @usernumber Thanks, that's a good idea! Unfortunately they are not. :-(  
> **username_2**: Have you worked with ImageJ?  https://imagej.nih.gov/ij/   It has some tools to do blob detection and similar stuff, developed at least partly with astronomers in mind.  
> **username_0**: @CarlWitthoft I've used it to make GIFs but haven't explored it otherwise. I'll try that today and see what happens. Ultimately I'm looking for a Python solution so I can integrate it into a workflow and also so I can *get under the hood* and modify and optimize it, but this could be a helpful stepping-stone.  
> **username_3**: The software that's most used for detecting things in astronomical images is [SExtractor](https://www.astromatic.net/software/sextractor) or the Python library [SEP](https://sep.readthedocs.io/en/v1.0.x/) which implements the same core algorithms.  
> **username_0**: @astrosnapper thank you, I'll have a look today. Hopefully I can find something that doesn't have a big learning curve and/or require FITS or some special format that I'll also have to construct, but if so, maybe it will be fun to learn!  
> **username_0**: @astrosnapper I've added a bounty to get a little more detail. These days I'm doing [this kind of thing](https://math.stackexchange.com/a/3829536/284619) so work on image processing is slow, but I've got to do it and I need something to compare to.  
> **username_0**: @student I'll take a look, thanks! There is symmetry in the underlying math, but there are distortions and tilts and some "stars" will disappear at times, so it's probably necessary to treat the spots as unrelated at this step .Why would SExtractor benefit from or need symmetry?  
> **username_0**: @student oh I see. Strictly periodic surface layers will each have 2, 3, 4, or 6-fold symmetry and it's okay to anticipate that, but these diffraction spots move around a lot and appear/disappear; that's basically what the experiment tries to make happen. Okay I will check it out for sure, thanks! btw does it only run on linux OS?  
> **username_0**: @student I am on macOS but I have no developer skills whatsoever. All I can do pip install X where X is some python package. I tried [this once](https://apple.stackexchange.com/q/327177/143729) got it installed, but didn't know what I was doing.  
> **username_0**: @student oh, how easy! Okay, installed and running, but now I will have to read up on how to write the job files (configuration and measurement) to go along with the image. If you write up a short answer with something basic based on the first image in the question just to get me started, I can accept right away. Either way, thank you very much!  
> **username_0**: btw I used `conda install -c conda-forge astromatic-source-extractor` from [here](https://anaconda.org/conda-forge/astromatic-source-extractor) which has an extra `-c` compared to your line, I hope it won't blow up.  
> **username_4**: Despite all the explanation, I think this question is off-topic here and on-topic and better answered in stackoverflow with the tag [image-processing]. That's true even more so as object detection of small particles or similar depends VERY HEAVILY on their excact properties and what is common about the objects, about the properties of the background and how you can treat reduction by that. PIV and particle recognition / shadowgraphy is a own subject in image-processing and analysis  
> **username_0**: @planetmaker That is a good point, and now armed with my own poor implementation and this package, I can write a better, more detailed question and post it there perhaps. I'm bootstrapping my way up here. This way nobody will ask "What have you tried so far?" or "Why not ask in Astronomy SE?" SO is much better than it used to be, but there are random, drive-by downers that can kill a question if you don't write it correctly. I've asked about 3,000 SE/SO questions now; I've found the bootstrap method works well and produces helpful and well-received answers most of the time.  
> **username_0**: @student the bounty expires in 2 days, then there's a 24 hour silent grace period. After that the points disappear into a black hole, and since reputation has no charge nor spin, they're truly lost. Consider writing a short answer?  

---

## 0 answers

