python - Crop an image, based on values -
orange represents values equal 0, white represent values equal 255, blue represents field, values vary 0 255. i rid of orange area, bit different in each image. best way that?
edit 1
i thought answer help: bounding box approach. except, array a_extract
, not a_trim
:
a = np.array([[0, 0, 0, 0, 0, 0, 0], [0, 255, 0, 0, 0, 0, 0], [0, 0, 255, 255, 255, 255, 0], [0, 0, 255, 0, 255, 0, 0], [0, 0, 255, 255, 255, 0, 0], [0, 0, 0, 255, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) a_trim = np.array([[255, 0, 0, 0, 0], [ 0, 255, 255, 255, 255], [ 0, 255, 0, 255, 0], [ 0, 255, 255, 255, 0], [ 0, 0, 255, 0, 0]]) a_extract = np.array([[255, 255, 255], [255, 0, 255], [255, 255, 255])
so basically, code should found bounding box, elements in first , last row (as in first , last column) should have same value (e.g. 255).
edit 2
the real image classified satellite image, stored numpy array (with shape cca. 7000x8000) , not rgb image. how looks like:
- orange = 0
- green = 2
- pink = 3
- white = 255
the aim rid of 0 values on edges.
the image posted has white border black lines on 3 sides before orange.
this remove white border change orange white:
convert amgch.png -trim -fill white -draw "color 5,5 floodfill" output.png
Comments
Post a Comment