I have images that have a white border around them. I'd like to get rid of that border at runtime.
A simple but slow algorithm to do that would be like this:
- Scan every row from the top down, stopping if a pixel in the row is non-white.
- Do the same for all 4 sides.
That way, I learn the width of the white border on each side, and can trim it accordingly.
The above method is rather slow, I suppose. Is there a more efficient way to accomplish this? I.e, does iOS offer any functions that help with this task?