15

I'm trying to add a stroke/border and a drop shadow around the non transparent pixels of a UIImage.

The goal is to get something that looks like this:

picture with white border and shadow

I've tried several things and am still trying to figure out exactly how to accomplish this.

In general I've tried:

  1. Adding a shadow to the UIImageView. (Shadow works, stroke/border is a rectangle instead of tracing out the non transparent pixels in the face. In addition I want to save the result as a UIImage (not have it just display on the UIImageView))

  2. Adding a shadow to UIImage (Slow and not sure how to add a border here).

Help is greatly appreciated! Thanks!

N V
  • 742
  • 1
  • 6
  • 21

1 Answers1

0

You can detect contours of image using findContours from OpenCV library: http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#findcontours

In this case you can get UIBezierPath bounding image and you can draw stroke with it.

Vitalii Gozhenko
  • 9,220
  • 2
  • 48
  • 66