diff --git a/404.html b/404.html index 7f06a96..2ec1c9c 100644 --- a/404.html +++ b/404.html @@ -42,7 +42,7 @@ - foto v1.1 + foto v1.2 @@ -60,6 +60,9 @@
diff --git a/CONDUCT.html b/CONDUCT.html index 25bc608..a4be50f 100644 --- a/CONDUCT.html +++ b/CONDUCT.html @@ -21,7 +21,7 @@ - foto v1.1 + foto v1.2 @@ -37,6 +37,9 @@ diff --git a/LICENSE-text.html b/LICENSE-text.html index a5d723d..c60a028 100644 --- a/LICENSE-text.html +++ b/LICENSE-text.html @@ -21,7 +21,7 @@ - foto v1.1 + foto v1.2 @@ -37,6 +37,9 @@ diff --git a/articles/foto-background.html b/articles/foto-background.html new file mode 100644 index 0000000..b6c43bf --- /dev/null +++ b/articles/foto-background.html @@ -0,0 +1,221 @@ + + + + + + + +vignettes/foto-background.Rmd
+ foto-background.Rmd
The FOTO (Fourier Transform Textural Ordination) method uses a +principal component analysis (PCA) on radially averaged 2D fourier +spectra to characterize (greyscale) image texture (of canopies). Here, +I’ll explain the underlying algorithm, with a worked example. This +should give you a better insight in how the algorithm works and how some +of the parameters influence your analysis.
+ +Note that the three boxes have very different textures.
+ +The next step in the algorithm is to transform the data using a +Fourier decomposition.
+
+# fft transform
+fftim_1 <- Mod(stats::fft(im_1))^2
+fftim_2 <- Mod(stats::fft(im_2))^2
+fftim_3 <- Mod(stats::fft(im_3))^2
The data now need to be radially averaged, so we calculate the +distance relative to the center of the image.
+
+# calculate distance from the center of the image
+offset <- ceiling(dim(im_1)[1] / 2)
+
+# define distance matrix
+# r is rounded to an integer by zonal
+distance_mask <- sqrt((col(im_1) - offset)^2 + (row(im_1) - offset)^2)
We first back convert all data to terra
objects
+(rasters), to make the raster math easier.
+# suppress warning on missing extent (which
+# is normal)
+fftim_1 <- terra::rast(fftim_1)
+fftim_2 <- terra::rast(fftim_2)
+fftim_3 <- terra::rast(fftim_3)
+distance_mask <- terra::rast(distance_mask)
Below you see the concentric mask and the 2D FFT frequency plot. +Note, unlike most conventional plots the data is not centered on 0.
+ + +For all FFT spectra the data will be radially averaged, removing any
+directional components from the data. The terra
zonal()
+function is used to do this efficiently.
+rspec_1 <- rev(
+ terra::zonal(
+ fftim_1,
+ distance_mask,
+ fun = "mean",
+ na.rm = TRUE
+ )[, 2]
+)
Plotting the averaged spectra shows subtle differences between the +different textures.
+ +Hufkens K (2024). foto: Fourier Transform Textural Ordination. -R package version 1.1, https://github.com/bluegreen-labs/foto. +R package version 1.2, https://github.com/bluegreen-labs/foto.
@Manual{, title = {foto: Fourier Transform Textural Ordination}, author = {Koen Hufkens}, year = {2024}, - note = {R package version 1.1}, + note = {R package version 1.2}, url = {https://github.com/bluegreen-labs/foto}, }diff --git a/index.html b/index.html index 1ab18fc..e78e757 100644 --- a/index.html +++ b/index.html @@ -49,7 +49,7 @@ - foto v1.1 + foto v1.2 @@ -67,6 +67,9 @@ diff --git a/news/index.html b/news/index.html index b28c2d6..709e35d 100644 --- a/news/index.html +++ b/news/index.html @@ -21,7 +21,7 @@ - foto v1.1 + foto v1.2 @@ -37,6 +37,9 @@ @@ -62,6 +65,11 @@
NEWS.md
+