# Astronomy PSF

**URL:** https://discourse.julialang.org/t/astronomy-psf/129430
**Category:** Astro/Space
**Tags:** question
**Created:** [May 29, 2025, 9:08am UTC](https://discourse.julialang.org/t/astronomy-psf/129430 "2025-05-29T09:08:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Cyan](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Cyan](https://discourse.julialang.org/u/Cyan)
#### Post date: [May 29, 2025, 9:08am UTC](https://discourse.julialang.org/t/astronomy-psf/129430/1 "2025-05-29T09:08:31Z")

</div>

If I have a PSF and a unconvolve image, Does there exist a expert PSF package to convolve the image?

---

<div class="post-metadata">

### Author: ![cgarling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgarling/32/29278_2.png) [@cgarling](https://discourse.julialang.org/u/cgarling)
#### Post date: [June 5, 2025, 2:04pm UTC](https://discourse.julialang.org/t/astronomy-psf/129430/2 "2025-06-05T14:04:35Z")

</div>

If you can load your PSF and your image as matrices, then you can compute the convolution with [ImageFiltering.jl](https://juliaimages.org/ImageFiltering.jl/stable/kernels/#Correlation,-not-convolution). More information is given in the docs, but a short demo is given below

```julia
using ImageFiltering: reflect, imfilter, centered

psf = centered(rand(5,5)) # Use `centered` to properly configure matrix indices
psf ./= sum(psf) # Normalize psf to unity sum
# ImageFiltering.jl performs image correlation, not convolution, so we reflect
# the PSF before passing into `imfilter`
kernel = reflect(psf) 
image = rand(100, 100)
conv_image = imfilter(image, kernel)
# `imfilter` supports many other options here (e.g., boundary conditions), see docs

```

---

<div class="post-metadata">

### Author: ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)
#### Post date: [June 5, 2025, 4:02pm UTC](https://discourse.julialang.org/t/astronomy-psf/129430/3 "2025-06-05T16:02:52Z")

</div>

And here’s another example [with doggies](https://computationalthinking.mit.edu/Fall24/images_abstractions/transforming_images/#7489a570-74a3-11eb-1d0b-09d41604ffe1)!
