Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding HSV, Lab, or other color modes #624

Closed
foresmac opened this issue Apr 15, 2014 · 6 comments
Closed

Adding HSV, Lab, or other color modes #624

foresmac opened this issue Apr 15, 2014 · 6 comments
Milestone

Comments

@foresmac
Copy link

Sometimes (well, actually, many times in image analysis) it's useful to work with image data in forms other than R,G,B 3-tuples. I've come up with some code to convert RGB to HSV (hue, saturation, and value or brightness), but I also can see where other conversions might be useful. The math is well known, but some conversions require either additional information (e.g. a reference white point), or some well-defined defaults. At first thought, it seemed as though this was best implemented as an image mode, but that might not really be the right semantics, since these other color representations don't really map to an image file format.

Perhaps this might be better implemented as utility functions? Properties on the Image class? I'd like to get some input from others before simply coding up a solution and submitting a pull request.

Fair warning: I know enough about color theory to be dangerous; not 100% confident I know enough on my own to do all the work myself. Therefore, I especially welcome input from anyone with experience in color spaces, perceptual color models, etc.

@wiredfool
Copy link
Member

So, a couple of things to look at:

  • ImageCMS is a good starting place for this, as it is where the color management is implemented. It's kind of tacked on and optional, but useful for certain types of things.
  • There is a LAB mode for reading LAB mode tiffs. However the only way to convert back and forth with RGB is to go through the ImageCms portion, due to the dependence on color temperature in the conversion.
  • HSV only shows up in one place, where it's a not implemented error.
  • There are also YCbCr and CMYK image modes that are used in certain special cases.

HSV would probably be a useful image mode, especially since I think that there are storage formats that use it. Conversions with extra parameters might be better off going through libcms, or, perhaps we could extend convert. However, we'd need to be careful on that one, since apis are forever.

@foresmac
Copy link
Author

Thanks for the input, @wiredfool!

HSV is, IME, the easiest thing to implement, and since it doesn't require any other parameters other than the RGB values, I'll look at adding a mode for it as a starting place.

Thanks for the pointer to ImageCMS—I'll explore that further as well.

I'll also examine the existing Lab mode and see if there are ways it can be enhanced or expanded for additional image analysis work.

I still welcome any and all additional feedback from the community.

@aclark4life aclark4life added this to the 2.5.0 milestone Apr 15, 2014
@aclark4life aclark4life modified the milestones: Future, 2.5.0 Jun 1, 2014
@hugovk
Copy link
Member

hugovk commented Jul 24, 2014

HSV implemented in #816.

@foresmac
Copy link
Author

Dang, I was going to work on this at our upcoming company-wide hack session. Thanks for jumping on it, @wiredfool.

@wiredfool
Copy link
Member

Sorry I preempted your hack session. I'd actually forgotten about this issue.

@foresmac
Copy link
Author

No big, just need to find another way to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants