Today I have managed to blur an image by using finger inputs which is placed on a UIImageView on iOS. I know it is not the best but the consequence was a great success. I used a box-blur algorithm that I have came up with today earlier. It is actually not a big deal to implement such algorithm but to make it high performance is. Mine is not slow but is not super fast either. I am not allowed to share such code but I can basically write about the steps;
- Get users finger’s touch coordinates. Be careful here if you are using retina display you need to multiply coordinates by 2 to get actual coordinates thats the trick here.
- Take that position as your center point and go up and left to find your rectangle’s starting point. (There are a lot of if checks here)
- Create a rectangle starting from that point and crop that part of the image into another UIImage.
- Blur that small piece of square with whatever algorithm you are using. (I have used box-blur, much faster than gaussian)
- Paste that small piece to the same place where you have taken it from.
- There you have blurred a part of an image, if you put this function in TouchesMoved function then you can get good results as I have.
Those are the steps I have followed while implementing my own. If you are not good with Maths then you should not try to do this on your own, it would take a long time to figure out what to sum or multiply. There are a lot of operations which drive you crazy sometimes.
Recent Comments