I was wondering how to determine the equivalent of RGB values for a grayscale image. The original image is grayscale and everything I have found online is converting an RGB image pixel values to the grayscale pixel values. I already can read in the image. Ideally, this would be for xCode.
我想知道如何确定一个灰度图像的RGB值。原始图像是灰度的,我在网上找到的一切都是将RGB图像像素值转换成灰度像素值。我已经可以在图像中阅读了。理想情况下,这将用于xCode。
I was wondering if there was a class which would do this for me. If so, and you could point me to it, that would be great. I will read on it.
我在想是否有一个班会为我做这件事。如果是这样的话,你可以指给我看,那就太好了。我来读一下。
Any help is greatly appreciated.
非常感谢您的帮助。
NOTE: I am a beginner in C++ and do not have time to learn everything formally; I have to learn all of my programming on the fly.
注:我是c++的初学者,没有时间正式学习一切;我必须在飞行中学习所有的编程。
2 个解决方案
#1
0
You need more information to transform from a simple Greyscale to RGB, when you do reverse operation, the color information is "lost", as the three channels are set to same value(depending on the algorithm each channel will have a different/same weight in the final color computation).
你需要更多的信息从一个简单的灰度变换到RGB,当你做反向操作时,颜色信息是“丢失”的,因为这三个通道的值是相同的(取决于算法每个通道在最终的颜色计算中会有不同的/相同的权重)。
Digital cameras, usually store more information per pixel, 12 bits per channel in 35mm and 14 bits per channel in medium format (those bits number are the average, some products offer less or even more quality).
数码相机,通常每像素存储更多的信息,35毫米的每个频道12位,中等格式的14比特(这些比特数是平均值,有些产品提供的质量更低,甚至更高)。
Thanks to those additional bits per channel, the camera can compute the "real" color, or what it thinks is the real color based on some parameters.
由于每个通道都有这些额外的比特,相机可以计算出“真实”的颜色,或者根据一些参数来判断真实的颜色。
TL;DR: You can't without more data from your source, in this case the image.
您不能没有来自您的源的更多数据,在这种情况下是图像。
#2
0
You can convert a gray value to RGB by setting each component of the RGB value to the gray value:
通过将RGB值的每个组件设置为灰度值,可以将灰色值转换为RGB:
ColorRGB myColorRGB = ColorRGBMake(myGrayValue, myGrayValue, myGrayValue);
#1
0
You need more information to transform from a simple Greyscale to RGB, when you do reverse operation, the color information is "lost", as the three channels are set to same value(depending on the algorithm each channel will have a different/same weight in the final color computation).
你需要更多的信息从一个简单的灰度变换到RGB,当你做反向操作时,颜色信息是“丢失”的,因为这三个通道的值是相同的(取决于算法每个通道在最终的颜色计算中会有不同的/相同的权重)。
Digital cameras, usually store more information per pixel, 12 bits per channel in 35mm and 14 bits per channel in medium format (those bits number are the average, some products offer less or even more quality).
数码相机,通常每像素存储更多的信息,35毫米的每个频道12位,中等格式的14比特(这些比特数是平均值,有些产品提供的质量更低,甚至更高)。
Thanks to those additional bits per channel, the camera can compute the "real" color, or what it thinks is the real color based on some parameters.
由于每个通道都有这些额外的比特,相机可以计算出“真实”的颜色,或者根据一些参数来判断真实的颜色。
TL;DR: You can't without more data from your source, in this case the image.
您不能没有来自您的源的更多数据,在这种情况下是图像。
#2
0
You can convert a gray value to RGB by setting each component of the RGB value to the gray value:
通过将RGB值的每个组件设置为灰度值,可以将灰色值转换为RGB:
ColorRGB myColorRGB = ColorRGBMake(myGrayValue, myGrayValue, myGrayValue);