Hello OF People,
I stumbled across an interesting problem and I’d thought I get directions from here. Now I do have an image in photoshop and I played with its colors and I want to have the exact same color formation with my camera through OF. Now what I did was, I sampled the darkest pixel in the image and also sampled the brightness pixel of this image.
The values are below:
brightest
R178 G149 B88
darkest
R17 G8 B2
I assumed I need to scale down my RGB values I am getting from the camera just like this brightest for the R should 178 darkest should be 17, brightest G should be 149, darkest R should be 8 and brightest B should be 88 and darkest should be 2.
Now I am getting R-G-B values with getPixel() and thanks to Jeremy, I used the below function to scale down the values:
int testApp::scale(int value, int input_min, int input_max, int output_min, int output_max) {
return ((value - input_min) * 100 / (input_max - input_min) * (output_max - output_min) + output_min)/100;
}
basically what I have is this:
for (int i = 0; i < camWidth; i++){
for (int j = 0; j < camHeight; j++){
colorPixels[(j*camWidth+i)*3 + 0] = scale(((pixels[(j*camWidth+i)*3 + 0]+pixels[(j*camWidth+i)*3 + 1]+pixels[(j*camWidth+i)*3 + 2])/3), 0, 255, 17, 178);
colorPixels[(j*camWidth+i)*3 + 1] = scale(((pixels[(j*camWidth+i)*3 + 0]+pixels[(j*camWidth+i)*3 + 1]+pixels[(j*camWidth+i)*3 + 2])/3), 0, 255, 8, 149);
colorPixels[(j*camWidth+i)*3 + 2] = scale(((pixels[(j*camWidth+i)*3 + 0]+pixels[(j*camWidth+i)*3 + 1]+pixels[(j*camWidth+i)*3 + 2])/3), 0, 255, 2, 88);
}
}
videoTexture.loadData(colorPixels, camWidth,camHeight, GL_RGB);
unfortunately the color I am getting is similar but not the exact formation that I am looking for. Actually, when I take a screenshot and put this in photoshop I am still getting darkest areas with 0,0,0. which should be 17,8,2. no? I am wondering if I am doing anything wrong with my approach to the problem.
I would appreciate any directions!
ilteris.