Home › Forums › The Learning Center › Color Theory and Mixing › CIECAM02 Viewer (Program)
- This topic has 9 replies, 3 voices, and was last updated 6 years, 7 months ago by Dcam.
-
AuthorPosts
-
July 28, 2017 at 10:34 am #995230
Hi folks,
Just wanted to share a program I wrote for displaying the CIECAM02 color space. I started this project, since I am unaware of any other CIECAM-based color space explorer. Feature creep also led to implementation of a color scheme generator, color palette rater, and image analyzer. It’s my first major programming project, so coding quality is probably crap, but it mostly works
It is currently available for windows(x64) here.
The readme can be found here.Anyhow, I think it’s best to explain things using screenshot, since most of us are visual-orientated:
Solid color space: This mode is very slow. I do not recommend trying to navigate the color space in this mode, but its nice to have, since it shows the exact edge of displayable colors.
The CIECAM02 sJh color space (constant saturation wheel when tilt = 0) is something I came up with, as an alternate to JCh (also available). Isn’t it pretty?
You should be able to cut through any plane in any colour space using the 4 control sliders.
Setting chroma to 0 and tilt degree to 90 gives you a Munsell-like view of the color space.
Color Picker: The color space, palette, and pigment below can be clicked on. Colors can be manually added to the palette (for storage or rating) using the Add1 to Add5 button. The Go! button will analyze will generate a visual of your palette and tries to analyze it.
Color Scheme Generator: Seems to work best when the C and J Span is set in moderation. You also don’t want any of the 5 colors outside of sRGB space, since those will not display accurately (The program will indicate this with !!! in the palette). Binding and reversing the second element (inversed J vs C) will also help if the color scheme generated looks too gnarly.
Nearest Pigment: These values were extracted from handprint.com. Unfortunately, not all pigment comes with JCh data, but most of the top40 pigments should be there. Note that watercolor masstone refers to paint that has been diluted to brushable consistencies and splotched on watercolor paper; It does not refer to freshly squeezed paint from the tube or dried half pans, which is the typical definition for oil/acrylic painters.
Image Analyzer: Selecting “map image gamut” will darken any colors not in your image in the color space explorer. Higher sampling rate will increase accuracy by sampling more pixels from your image (10000 vs 2000 pixels sampled; not really slow but try not to combine it with the solid wheel type). Sampling is random, and clicking analyze image will re-sample the image. If you see certain color circles turning on/off, it means that that color is rare enough in the image that it is sometime missed by the sampling – good way to check if it’s a superficial jpeg artifact when analyzing photos.Any comments & bug reports on my program is appreciated.
Discussion of CIECAM02 or the source papers is also appreciated, though keep in mind, that I’m in no way an expert in this.Long,
Long,
July 28, 2017 at 10:40 am #1271648Close up of the controls since the screenies got resized:
Long,
July 28, 2017 at 12:13 pm #1271652A quick look shows that it works (Win 64). I see that you post the source code, so maybe I can compile it on Linux too.
(1) I don’t see a way to close the program. That is, there is no main menu bar. If it is there, it is positioned off-screen. I know how to exit the program using Windows platform, but most users won’t know how to do that.
(2) When idle, it uses about 40% CPU. Doesn’t seem to slowly increase, the way it would with memory leaks. However, I wonder if there are some memory leaks in the code that launches it.
Prospective users should realize that much of the CIECAM02 color gamut is outside the gamut of a typical home computer monitor. So, many of the colors (particularly the most chromatic) are only “suggestive” of the real color.
July 28, 2017 at 1:11 pm #1271649A quick look shows that it works (Win 64). I see that you post the source code, so maybe I can compile it on Linux too.
(1) I don’t see a way to close the program. That is, there is no main menu bar. If it is there, it is positioned off-screen. I know how to exit the program using Windows platform, but most users won’t know how to do that.
(2) When idle, it uses about 40% CPU. Doesn’t seem to slowly increase, the way it would with memory leaks. However, I wonder if there are some memory leaks in the code that launches it.
I don’t have linux installed right now, but I do have the CMakeLists.txt that I used to compile it for linux in the past if you’re interested. It needs to be fixed it up a bit since I ported the project to Visual Studio.
I actually still have an older binary for linux, but I think I made some major calculation changes in the Kansei scale part of the program. The rest of the program should be the same, but I rather not upload it and cause confusions.1. Yup, you can close the windows using the close button or by hitting alt-F4 (this is defined in the program itself, so it should work on all platform). edit: actually, I looked into the code again, and it looks like I’m letting SFML handle the window closing events, so you close the program however you normally close the program in whatever OS you’re using. I also noticed that Pinguino might be using a lower res screen, which might be what is causing this problem. The windows should be resizable, but that might be hard depending on how it’s positioned on the screen. I’ll try and fix this later.
2. It actually use up an entire core. This is a property of SFML, which was designed for games, unfortunately. If it’s using up 40% of your CPU, then I’m guessing you have a dual core CPU. I have a quad core, so it only use ~20% of my CPU. It was something I didn’t realize until I began learning this framework, and was too invested by the time I found out to switch over to something else. It might to worth it to rewrite this in .Net or something.
Prospective users should realize that much of the CIECAM02 color gamut is outside the gamut of a typical home computer monitor. So, many of the colors (particularly the most chromatic) are only “suggestive” of the real color.
This is quite important to note
Here’s a sample CMakeLists.txt in case you need it (main.cpp no longer exist + some case sensitivity stuff + maybe a bunch of other changes are required).
[code]
cmake_minimum_required(VERSION 2.6)
project(ciecamviewer)include_directories(“./imgui”)
add_executable(ciecamviewer main.cpp ciecamviewer.cpp colorwheel.cpp color.cpp viewingcondition.cpp colorschemer.cpp pigmentlocator.cpp imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui-SFML.cpp imgui/imgui_demo.cpp)
set(CMAKE_MODULE_PATH “${CMAKE_SOURCE_DIR}/cmake_modules” ${CMAKE_MODULE_PATH})
find_package(SFML 2 REQUIRED system window graphics audio)
find_package(OpenGL)include_directories(${SFML_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
target_link_libraries(ciecamviewer ${SFML_LIBRARIES} ${OPENGL_LIBRARIES} -lstdc++fs)install(TARGETS ciecamviewer RUNTIME DESTINATION bin)
[/code]Long,
July 28, 2017 at 8:07 pm #1271653Don’t worry about Linux. I dual boot, and manage color on Windows.
Yes, dual core.
July 29, 2017 at 12:42 am #1271645Very impressive, for a first major coding project!
I’m looking to code a graphics project, something less-complex than what you have, but that includes the CIECAM02 calculations. I’m looking to code it either in a language that produces Java bytecode – either JRuby (which I know) or Clojure (which I’m still learning).
So I see my options are to either just code the CIECAM02 equations, that I see are available on Wikipedia, directly into either JRuby or Clojure, or call a Java library (one probably already exists somewhere) from either language. A third possibility is that a Ruby or Clojure graphics library already exists that includes the CIECAM02 code, although I’m not too hopeful about that. I’ll have to check.
So, since it looks like I’ll be trying to do the same, I’m curious about the approach you took to incorporating the CIECAM02 equations into your own code. Would you mind sharing that?
AJ (opainter), C&C always welcome
:::: Helpful links for new users: User Agreement || Reference Images || C&C Suggestions || Color Theory and Mixing (color theory and color selection) || Full List of Forums
:::: Painting Blog with an article now and thenJuly 29, 2017 at 11:02 am #1271650Well, if you can’t find a library for it (I couldn’t find any for C++), here’s how I approached it:
For the sRGB <-> CIEXYZ conversion, I used http://www.easyrgb.com/en/convert.php, which has a colour converter and some pseudo codes. The converter on this website gives incorrect results for very dark values in both the forward and reserve model, but it’s fairly accurate otherwise. By incorrect, I mean totally off: not attached to the color solid and flying off into void incorrect (likely due to the special case where RGB < ~4). The pseudo code looks correct, though. For the CIEXYZ <-> CIECAM conversion, I cross-checked my results using this program by Billy Biggs: http://scanline.ca/ciecam02/. Unfortunately, this program requires compiling, so I recommend just using my program if you need to cross-check your work (The results are the same). For coding, I relied on a book written by Mark Fairchild (Color Appearance Models). Wikipedia is probably okay, but I recommend the book if you get stuck. Wikipedia also renamed a lot of the variables for some reason, which makes it difficult to follow wikipedia and official sources at the same time.
The book and wikipedia is missing one of the transformation matrix needed for the reversed model (CIECAM->CIEXYZ), which I had to hunt down in one of Mark Fairchild’s older paper. I forgot which paper (or which matrix for that matter), but you can pull it from Billy Biggs’ or my own source files (at the bottom of viewingcondition.cpp) if you can’t find it.
JRuby and Clojure is quite different from C++, but feel free to take a look at color.cpp and viewingcondition.cpp, which is where all the colour conversion calculation takes place.
My only other advice is to do a couple of calculation by hand, so that you have known good intermediate values to debug your program with. Especially with the reserved model, which requires quite a bit of algebra, since neither the book or wikipedia will hand feed those formulas to you.
Have fun!
PS I’m curious about your graphic project
Long,
August 3, 2017 at 1:24 am #1271646You’ve given me some great information about the color conversions, and I expect to find it helpful! Thank you!
PS I’m curious about your graphic project
This application would translate images into cross-stitch patterns for making fairly-detailed original fabric art. Wikipedia’s article shows six examples of simple/”sampler” designs, and then one example of what I’m thinking.
I would like to use the CIECAM02 equations (conversions) to let the user apply a filter to the image to change its “visual contrast.”
Of the JVM languages, Clojure and JRuby have got to be the best – besides Java itself, of course! – due to their reliability and intuitive interfaces to Java’s Swing (user interface) library and other core libraries. I’ve chosen to use JRuby.
I’m not doing this to make money off the software – too many cross-stitch conversion programs already exist out there – but I do hope to use it to make my own cross-stitch patterns, to then make and sell!
That’s all for now!
AJ (opainter), C&C always welcome
:::: Helpful links for new users: User Agreement || Reference Images || C&C Suggestions || Color Theory and Mixing (color theory and color selection) || Full List of Forums
:::: Painting Blog with an article now and thenAugust 29, 2017 at 1:27 am #1271647I’m just popping up here to say that I have not forsaken my project to use the CIECAM02 equations. I’ve forked your Github files, Long (thanks!), and intend to start working on that pretty soon. I’ll keep you posted! Check back . . .
AJ (opainter), C&C always welcome
:::: Helpful links for new users: User Agreement || Reference Images || C&C Suggestions || Color Theory and Mixing (color theory and color selection) || Full List of Forums
:::: Painting Blog with an article now and thenAugust 30, 2017 at 3:59 pm #1271651Glad my program was of help to you! Good luck with your project
Long,
-
AuthorPosts
- The topic ‘CIECAM02 Viewer (Program)’ is closed to new replies.
Register For This Site
A password will be e-mailed to you.
Search