This is the formula that we use to convert RGB to respective CMY format:
C = 1 - ( R / 255 ) M = 1 - ( G / 255 ) Y = 1 - ( B / 255 ) I am trying to display the CMY image after applying this formula to RGB values of the original image, but the resultant values that I get are between 0 and 1. I don't think this range can be used to display an image.
How do I store CMY values as an array so that they can be used to display the image? Do I have to scale the range of 0-1 to 0-255 for that?
If I have to scale then, why this formula is used, I can directly use:
C = 255 - R M = 255 - G Y = 255 - B 72 Answers
#include <iostream> using namespace std; int main() { float C = 1.0f - (R / 255.0f); float M = 1.0f - (G / 255.0f); float Y = 1.0f - (B / 255.0f); float cmyArray[3] = {C, M, Y}; return 0; } This code will store the C, M, Y variables as floating points and then create an array for 3 floating points to be pushed in. In this case it starts off with the values C, M, and Y already initialized into the array.
If you need many values then you could address the nth cmy group as such: n*3 + x where x is 0 for c, 1 for m and 2 for y.