# How to upscale an image using a Gaussian filter in R?

I want to resample a raster from 15m to 460m using a Gaussian filter.

The goal

I am having a coarse image which I want to downscale. I also have a fine resolution band to assist the downscaling. The downscaling method I am using is called geographically weighted area-to-point regression Kriging (GWATPRK). The method consists of two steps:

1. GWR
2. area-to-point Kriging on the GWR's residuals

In order to perform GWR using raster data, those needs to have the same pixel size. This means that, my fine resolution image needs to be upscaled to match the spatial resolution of the coarse band. This upscaling of the fine band needs to be done using a Gaussian kernel with $$\sigma = 0.5$$(i.e., the PSF).

How can I upscale (reduce the spatial resolution) a satellite image using a Gaussian kernel (i.e., point spread function)?

For reference, I am following the paper The effect of point spread function on downscaling continua where the authors at p.253 in Eq (9) mention:

the coarse image produced by upscaling the corresponding fine band k using a PSF.

I googled how I can achieve that but unfortunately I couldn't find any solution. So to do this, how can I use this Gaussian filter to change the resolution of my image with R?

Here is the image I am trying to convolve:

• Where's the image?
– Jdip
Sep 2, 2022 at 23:58
• Could you please copy an paste the code from post into R? That's my image, I used the dput function in order to share it. Sep 3, 2022 at 6:20
• I'm going to have a hard time loading "C:\\Users\\nikos\\OneDrive\\Desktop\\pan15.tif" ! Please see Help, and look for "Images"
– Jdip
Sep 3, 2022 at 14:31
• I posted a link from my Gdrive where you can download the image. Sorry for the inconvenience Sep 3, 2022 at 15:07
• “How can I upscale (reduce the spatial resolution)” upscaling typically involves increasing the spatial resolution, not reducing it, though it is perfectly possible (and easier) to upscale preserving the resolution (ie apply plain old interpolation). Parts of your post say “downscale”, parts say “upscale”. This is very confusing. Oct 4, 2022 at 18:55

## 1 Answer

Using «upscale» about downscaling an image seems confusing.

In MATLAB and pretty much any package the most straight forward approach to Gaussian filtered downsampling would be:

1. Generate a vector of samples of a truncated Gaussian of appropriate variance
2. Convolve the input image with the vector from 1 in each dimension
3. Drop samples (pick every n-th) on each dimension

There certainly are more optimal ways to do this (polyphase filtering), and your package may have built in image scaling with Gaussian as an option.

• I edited my post in order to make my problem more clear, I'm sorry that I didn't that from the beginning. All in all, the reason for the upscaling is because I want to perform regression between two raster data. This means that my data needs to have the same pixel size in order to do that. During the regression (and later the downscaling process for that matter) I want to account for the point spread function (which I assume it's Gaussian). To account for the PSF I upscale the fine resolution image using a Gaussian filter with sigma (std) = 0.5. I hope I made my problem more clear now. Sep 3, 2022 at 23:47
• In Matlab I have found this post (dsp.stackexchange.com/questions/44159/…) which they are doing, almost, what I want. There are some differences of course, like for instance, how they import the image. But in general, that is the solution using Matlab. Oct 4, 2022 at 19:31