0

How to programmatically change the hue of UIImage?

I am using the above page's advice, for Core image filter CIFilter. The only problem I am having is my when I rotate to a yellow hue, it's a dark mustard yellow, and I can't get the brightest vibrant yellow, ie R:255 G:255 B:0. I have images that are on layers that are made up of a simple color R:255 G:0 B:0 I just want to rotate around, to get the basic colors plus orange. Orange works fine tho.

I just don't know why when I rotate from R:255 to try and get R:255 G:255 Yellow it's a dark yellow.

I am using 1.04719755 for the Yellow float, at deltaHueRadians

I don't know it's just weird this is the 3rd attempt at this but I keep getting a dingy yellow.

Community
  • 1
  • 1
rezwits
  • 835
  • 7
  • 12

1 Answers1

1

I realized the problem.

In Photoshop I have done so many Colorize operations when I used to photo edit, I got them confused with Hue Rotation.

Basically when you Colorize in Photoshop, it will "Colorize" the image not just Hue Rotate the values.

The difference between the two is a very thin line depending on what images you use. I don't really feel like going into a complete explanation but...

Say you have a grey cube on a layer, and you COLORIZE the image, the cube will rotate colors as you use a slider. If you Hue rotate it will stay grey.

But if you take a red cube, and hue rotate, then the hue rotation will take you thru colors, not necessarily all of them tho like a colorize.

I believe the issue has to do with all that good ole HSV RGB matrix crazy math problems. Which I am not doing right now. Keeping it simple.

I decided to just do a colorize method with:

CGContextSetBlendMode(context, kCGBlendModeMultiply);

With grey objects and this is perfectly what I wanted.

from googling I found this:

http://coffeeshopped.com/2010/09/iphone-how-to-dynamically-color-a-uiimage

rezwits
  • 835
  • 7
  • 12