python - Crop an image, based on values -


i have multiple images, this: enter image description here

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.

enter image description here

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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -