-1

I am new for iOS Development . After googling I found that, it is easy to blur whole image but it is difficult to blur specific part of image such like rectangular or circular. So please help me how can I blur specific part of image rather then whole image ?

Thanks in advance.

app_
  • 697
  • 5
  • 12
  • 2
    can you include the code you are using to blur the full image?, this can be useful to get an answer – tkanzakic Dec 10 '12 at 09:58
  • @ tkanzakic -search on GOOGLE, i found that... https://github.com/coryleach/UIImageAdjust, https://github.com/esilverberg/ios-image-filters, https://developer.apple.com/library/ios/#samplecode/GLImageProcessing/Introduction/Intro.html site for blur image but i can't get correct answer :( –  Dec 10 '12 at 10:17
  • u kn this is custom control for blur partially img –  Dec 10 '12 at 10:19
  • 1
    I don't have to search in google for that, you have a problem and I'm trying to help you, and to do it I need more information about what you are doing – tkanzakic Dec 10 '12 at 10:20
  • 2
    Or to put it another way: He's not asking what *other* people are doing; he's asking what *you* are doing. – Peter Hosey Dec 10 '12 at 19:24

1 Answers1

1

Blur the whole image, then crop to the part you care about. You can use a mask for non-rectangular/non-sharp-edged blurs, but don't skip the crop.

The lovely, but sometimes tricky, thing about Core Image is that it's extremely lazy. It doesn't work from the start to the end; it's more of a pull model, working from the last thing you asked for all the way back to the original rasters. Moreover, it won't actually filter any pixels you have not asked for.

So, in your case, a crop means not asking for any blurred pixels outside of the crop. Since you didn't ask for them, they don't get blurred. The blur only runs on the pixels you ask for—the ones inside the crop.

Masking works differently; by definition, it needs to look at every pixel in the mask image, and I would be surprised if it didn't also look at every pixel in the source (even to multiply it by zero). This is why you should still crop, even with a mask.

Note that the blurred-and-cropped portion of the image will still be where it is in the original image. It doesn't copy/move the pixels within the image, because that would be expensive; instead, it returns an image with a different extent—namely, the crop rectangle. You'll want to retrieve that extent and subtract its origin from the coordinates where you want to draw the image—either that or use an affine transform filter, but, again, that would probably be expensive.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370