image processing - Python array manipulation using numpy -
i trying replicate border of array:
a=[1,2],[3,4]
and want result as
[1,1,1,2,2,2] [1,1,1,2,2,2] [1,1,1,2,2,2] [3,3,3,4,4,4] [3,3,3,4,4,4] [3,3,3,4,4,4]
how do in python? using
import numpy (a,2,reflect') or wrap not getting array
you can utilize nested repeat
method (example in ipython):
in [1]: import numpy np in [2]: = np.array([[1,2],[3,4]]) in [3]: a.repeat(3, 1).repeat(3, 0) out[3]: array([[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4]])
but image manipulation migth want have @ e.g:
python imaging library (or newer variant, pillow) python interfaces imagemagick suiteespecially imagemagick provides lot of image manipulation tools.
python image-processing numpy scipy
No comments:
Post a Comment