I have a dataframe that contains pixels coordinates and its RGB and CIElab value for each.
These values are abstracted from a certain image. After changing some RGB/CIElab value in this dataframe, I would like to let the 'data' go back to an 'image'.
I include a sample with variable r, g, b, x, and y. r, g, and b contain the RGB value of each pixel.x and y indicate the pixel's coordinate.
So basically, I would like to create a picture with three color channels(rgb) with this dataframe. But I have no idea how to implement the process. Abstracting RGB value from image is easy. However, inversing the process is quite difficult.
r g b x y
1 0.91373 0.72157 0.45098 1 1
2 0.86275 0.59216 0.21961 2 1
3 0.84314 0.56471 0.18039 3 1
4 0.83922 0.56078 0.17647 4 1
5 0.84314 0.56471 0.18039 5 1
6 0.84706 0.56863 0.18431 6 1
7 0.85098 0.57255 0.18824 7 1
8 0.85490 0.57647 0.19216 8 1
9 0.85490 0.57647 0.19216 9 1
10 0.85098 0.57255 0.18824 10 1
Update:
I tried to use as.cimg
function
my_cimg <- as.cimg(unlist(rgb_image[1:3]), x=length(unique(rgb_image$x)), y=length(unique(rgb_image$y)),cc = 3)
And it works!!!
Thanks!