# HG changeset patch
# User imgteam
# Date 1712244222 0
# Node ID 6c4b22ef2b81201cf055a047cf7cf6fa33e0cd6c
# Parent f70b215d155c35d7bef530c0b7fd4b62c6393fda
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_simple_filter/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
diff -r f70b215d155c -r 6c4b22ef2b81 creators.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/creators.xml Thu Apr 04 15:23:42 2024 +0000
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r f70b215d155c -r 6c4b22ef2b81 filter.xml
--- a/filter.xml Fri Nov 10 13:44:57 2023 +0000
+++ b/filter.xml Thu Apr 04 15:23:42 2024 +0000
@@ -1,49 +1,135 @@
-
- with scikit-image
+
+ with scipy
+
+ creators.xml
+ tests.xml
+ 1.12.0
+ 0
+
+
+
+
operation_3443
- scikit-image
- scikit-image
+ scipy
- scikit-image
- numpy
- pillow
- tifffile
+ scipy
+ numpy
+ scikit-image
+ tifffile
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- **What it does**
+
+ **Applies a standard filter to a single-channel 2-D image.**
- Applies a standard filter to an image.
+ Mean filters like the Gaussian filter or the median filter preserve both the brightness of the image, and the range of values.
+
10.1016/j.jbiotec.2017.07.019
diff -r f70b215d155c -r 6c4b22ef2b81 filter_image.py
--- a/filter_image.py Fri Nov 10 13:44:57 2023 +0000
+++ b/filter_image.py Thu Apr 04 15:23:42 2024 +0000
@@ -1,29 +1,28 @@
import argparse
-import sys
-import skimage.filters
+import scipy.ndimage as ndi
import skimage.io
import skimage.util
-from skimage import img_as_uint
from skimage.morphology import disk
-filterOptions = {
- 'median': lambda img_raw, radius: skimage.filters.median(img_raw, disk(radius)),
- 'gaussian': lambda img_raw, radius: skimage.filters.gaussian(img_raw, sigma=radius),
- 'prewitt': lambda img_raw, radius: skimage.filters.prewitt(img_raw),
- 'sobel': lambda img_raw, radius: skimage.filters.sobel(img_raw),
- 'scharr': lambda img_raw, radius: skimage.filters.scharr(img_raw),
+filters = {
+ 'gaussian': lambda im, sigma: ndi.gaussian_filter(im, sigma),
+ 'median': lambda im, radius: ndi.median_filter(im, footprint=disk(radius)),
+ 'prewitt_h': lambda im, *args: ndi.prewitt(im, axis=1),
+ 'prewitt_v': lambda im, *args: ndi.prewitt(im, axis=0),
+ 'sobel_h': lambda im, *args: ndi.sobel(im, axis=1),
+ 'sobel_v': lambda im, *args: ndi.sobel(im, axis=0),
}
if __name__ == "__main__":
parser = argparse.ArgumentParser()
- parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file')
- parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)')
- parser.add_argument('filter_type', choices=filterOptions.keys(), help='conversion type')
- parser.add_argument('radius', default=3.0, type=float, help='Radius/Sigma')
+ parser.add_argument('input', type=argparse.FileType('r'), help='Input file')
+ parser.add_argument('output', type=argparse.FileType('w'), help='Output file (TIFF)')
+ parser.add_argument('filter', choices=filters.keys(), help='Filter to be used')
+ parser.add_argument('size', type=float, help='Size of the filter (e.g., radius, sigma)')
args = parser.parse_args()
- img_in = skimage.io.imread(args.input_file.name)
- res = img_as_uint(filterOptions[args.filter_type](img_in, args.radius))
- skimage.io.imsave(args.out_file.name, res, plugin='tifffile')
+ im = skimage.io.imread(args.input.name)
+ res = filters[args.filter](im, args.size)
+ skimage.io.imsave(args.output.name, res, plugin='tifffile')
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input1_gaussian.tif
Binary file test-data/input1_gaussian.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input1_median.tif
Binary file test-data/input1_median.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input1_prewitt_h.tif
Binary file test-data/input1_prewitt_h.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input1_prewitt_v.tif
Binary file test-data/input1_prewitt_v.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input1_sobel_h.tif
Binary file test-data/input1_sobel_h.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input1_sobel_v.tif
Binary file test-data/input1_sobel_v.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input1_uint8.tif
Binary file test-data/input1_uint8.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input2_float.tif
Binary file test-data/input2_float.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/input2_gaussian.tif
Binary file test-data/input2_gaussian.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/res.tif
Binary file test-data/res.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 test-data/sample.tif
Binary file test-data/sample.tif has changed
diff -r f70b215d155c -r 6c4b22ef2b81 tests.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests.xml Thu Apr 04 15:23:42 2024 +0000
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+