How to assign to each pixel of a raster value of the biggest difference between values of all pixels around it to a mask on 1 picture (red pixels and everything that after them is not included, black pixels and everything that inside of them are included).
Here is an example of how it works on 2 picture. I wrote such pseudo-code with Python assuming that as input i get list with all closest pixels using as a Central pixel lower left a corner 2 pictures of the. I do not understand how this can be transformed into a script for QGIS or Raster Calculator.
I tried in R the neighbour's module, but every time I set a radius greater than or less than 3 it throws an error. Also, you can take pixels not only for this mask but also for a circular radius of 128 meters. (For images of Landsat with a spatial resolution of 30x30). With what should I implement this?
near_pixels_list = [4, 1, 3, 3, 5, 8, 4, 1, 3, 0, 0, 7, 7, 4, 3, 0, 2, 1] center_pixel = 4 output = max(list(map(lambda x: max(center_pixel, x) - min(center_pixel, x), near_pixels_list)))