Hello, comrades.
I wrote shell script <i.landsat.trim>, that trims the “fringe” from the borders of Landsat images, for each band separately or with the MASK where coverage exists for all bands. Optionally saves vector footprints of trimmed rasters and MASK. Works with Landsat 5, Landsat 7 (SLC-on).
Link: https://raw.github.com/amuriy/GRASS-scripts/72f039073ff55b006b7aecbaa7870fac193dd9b3/i.landsat.trim
Usage:
i.landsat.trim [-maf] [input=string] [input_base=string]
[input_prefix=string] output_prefix=string [rast_buffer=value]
[gener_thresh=value] [–verbose] [–quiet]
Flags:
-m Trim raster(s) with the MASK where coverage exists for all bands
-a Process all bands
-f Save vector footprint(s) of trimmed raster bands or coverage MASK
–v Verbose module output
–q Quiet module output
Parameters:
input Name of input raster band(s)
Example: L5170028_02820070521_B10
input_base Base name of input raster bands
Example: L5170028_02820070521
input_prefix Prefix name of input raster bands
Example: ‘B.’ for B.1, B.2, …
output_prefix Prefix for output raster maps
Example: ‘trim’ generates B.1.trim, B.2.trim, …
rast_buffer Distance for raster buffering (in meters)
default: 300
gener_thresh Threshold for generalizing of vector footprints or coverage MASK (in meters)
default: 3000
Picture with example attached.
It was made “just for fun”, but I hope it would be useful for somebody 
Best regards,
Alexander
I attached picture with example of <i.landsat.trim> work.
Best regards,
Alexander
(attachments)

Alexander Muriy wrote:
...shell script <i.landsat.trim>, that trims the "fringe" from the
borders of Landsat images, for each band separately or with the MASK where
coverage exists for all bands.
..
Usage:
i.landsat.trim [-maf] [input=string] [input_base=string]
[input_prefix=string] output_prefix=string [rast_buffer=value]
[gener_thresh=value] [--verbose] [--quiet]
..
Parameters:
..
rast_buffer Distance for raster buffering (in meters)
default: 300
..
Hello Alex!
I am testing <i.landsat.trim>. Nice work! I do have a question though:
how do we interpret exactly the "rast_buffer" parameter?
Testing on a single L5T band, I get strange (to me) results with various buffer
distances (e.g., 100, 150, 200, 5000, 10000). Where does the buffer start?
Does it start from the outer non-NULL pixels of the image for example? Is it
expected that some distance (e.g. 100) will result in an (almost) empty image?
Any help appreciated in gaining complete control over the module's
functionality.
Best regards, Nikos
2012/12/21 Nikos Alexandris <nik@nikosalexandris.net>
I am testing <i.landsat.trim>. Nice work!
Thanks, Nikos!
how do we interpret exactly the “rast_buffer” parameter?
“rast_buffer” is the “service” parameter, which is used for several actions with the input raster bands. First of all, it identifies the width of raster buffer zone for making the band mask; also it controls the resolution of region during processing. It was gained experimentally with the best value near 300 meters for Landsat 7 images (sounds not very logical, I understand).
Testing on a single L5T band, I get strange (to me) results with various buffer
distances (e.g., 100, 150, 200, 5000, 10000). Where does the buffer start?
Does it start from the outer non-NULL pixels of the image for example?
Yes, the buffer start on the border of the band mask, but with the significantly coarser region resolution. 10000
Is it
expected that some distance (e.g. 100) will result in an (almost) empty image?
Can be expected almost anything, that’s why the module needs some work to make it more logical and more usable. I already started rewriting it in Python, along the way I’ll try to complement it and fix some functions.
Best regards,
Alexander.