Skip to content

Instantly share code, notes, and snippets.

View celoyd's full-sized avatar

Charlie Loyd celoyd

View GitHub Profile
@celoyd
celoyd / despeckling.md
Last active September 1, 2021 14:47
Learning to despeckle sar with speckly targets

Learning to despeckle sar with speckly targets

These are notes from a one-day project to test a hunch. The idea is to train a convolutional neural network to remove speckle from sar (synthetic aperture radar) using only one other observation – with its own speckles – as the target. This method does not come close to state of the art despeckling, and can be biased by the skewed distribution of noise in a way that makes it useless for quantitative research. However, I hadn’t noticed it in the literature and I think it’s kind of funny, so I’m writing it up.

Everything here is about Sentinel-1 L1 GRD-HD data, since it’s what I used, since it’s free.

Speckle

Sar observations contain speckle, a form of interference related to the sparkles in reflected laser light. By some definitions speckle is not noise, since it’s physically real outside the sensor and contains information, but we will treat it as noise. Speckle is (close enough to) independent between radar chirps, a.k.a. looks, and even its distributio

Pansharpening notes, mid-2021

First posted in August 2021. This is basically a snapshot of my thinking about pansharpening at that time; I’m not making any substantial updates. Last typo and clarity fixes in February 2023. December 2025 update: many ideas here, and some newer ones, are demonstrated in Potato.

Preface

This is a collection of notes on how I’ve been approaching convolutional neural networks for pansharpening. It’s an edited version of an e-mail to a friend who had asked about this tweet, so it’s informal and somewhat silly; it’s not as polished as, say, a blog post would be. It’s basically the advice I would give to an image processing hobbyist before they started working on pansharpening.

If you want a more serious introduction, start with the literature review in [Learning deep multiresolution representations for pansharpening](https://ar

#!/usr/bin/env python
# Demo a brightened luminance-only inversion on 8-bit images
from skimage import io
import numpy as np
from sys import argv
# RGB <-> YCoCg-R almost straight from Wikipedia
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Free Idea: Enhancing Astronaut Photography of Earth

Beta version. May contain bad ideas.

By a free idea I mean something that I think is probably fun and probably possible but that I don’t have the combination of time, skill, energy, patience, etc. to do myself. I hope someone does this. I hope someone reads this and does just the specific part that they’re interested in. I’m trying to get the idea out there without giving the impression that it’s my project. It’s just an idea.

To do the whole thing as laid out here I think you’d need at least an intermediate understanding of convolutional neural networks for image processing, access to a GPU, some sense of geography and astronomy (to gut-check your intermediate results), and a reasonable internet connection to download the images.

The idea

import himawari.HimawariScene as hsd
from sys import argv
import rasterio as rio
import numpy as np
scaleup = 64
scene = hsd.HimawariScene(argv[1])
rad = scene.radiances()
# python pca_multiband.py input.jpeg output.tif
# n-band image -> PCA -> n-band TIFF image
# with lots of hackety assumptions
# (e.g., output is same type as input)
from sys import argv
import rasterio as rio
import numpy as np
from sklearn import decomposition
@celoyd
celoyd / iss-neffer.py
Last active August 12, 2024 17:59
Download Nikon raw images from https://eol.jsc.nasa.gov/
# python neffer.py 55 111879
# mission ^^ ^^^^^^ frame
# will write to iss055e111878.nef.
# This code is public domain; please improve & adapt it.
import requests
from sys import argv, exit
from random import uniform
from time import sleep
@celoyd
celoyd / rs.md
Last active November 13, 2019 22:58
Robosat workshop guide
#!/usr/bin/env python
# simple visualization of the Co/Cg plane of an image
# https://en.wikipedia.org/wiki/YCoCg
from skimage import io
import numpy as np
from sys import argv
src = io.imread(argv[1])