I am trying to trim parts of the image where a complete row of Image doesn't have anything except white color.
I tried using matplot lib
convert image into matrix and saw if (r,g,b) = (0,0,0) or (1,1,1) and removed entire row in image if every (r,g,b) is of above kind in the row
matrix looks like [ [ [r,g,b], [r,g,b]....] ],...., [ [r,g,b], [r,g,b]....] ] ]
i achieved my requirement but i am running this for around 500 images and it is taking 30 minutes around. Can i do it in better ways?
and the required image should be like
Edit-1 : tried with trim method from wand package
with wand_img(filename=path) as i:
# i.trim(color=Color('white'))
# i.trim(color=Color('white'))
i.trim()
i.trim()
i.save(filename='output.png')
but not working for the following type of images





