0

I need to randomly generate the contrast of a UIImage. How do i do so? Also if you could tell me how to do the same for hue, brightness, sharpness, saturation, ect.

MikeE
  • 41
  • 1
  • 5

2 Answers2

0

you can generate a random number this way:

int x = arc4random() % 1000;

that generates a random number between 0 and 999. a float you can generate with:

#define ARC4RANDOM_MAX      0x100000000

double myValue = floorf(((double)arc4random() / ARC4RANDOM_MAX) * 10.0f);
thorb65
  • 2,696
  • 2
  • 27
  • 37
-1

You can use this image filtering category

https://github.com/esilverberg/ios-image-filters

and just go:

[myImage brightness:arc4random() % 256 / 255]
Andrew
  • 3,166
  • 21
  • 32
  • 1
    due to automatic reference counting, many lines in the github project are errors and warnings. Im not totally sure how to get around them... – MikeE Dec 23 '13 at 18:18