Representing a pixel's color vector in 3D RGB space and transforming into 2D space
4 次查看(过去 30 天)
显示 更早的评论
I have been trying to implement the paper "Wang, Yinglong & Liu, Shuaicheng & Zeng, Bing. (2018). Removing rain streaks by a linear model. " I am not able to implement the following portion of the paper.
The color characteristics of rain can be used to identify the mis-detected rain pixels. For a given pixel
, use
to represent its color vector in RGB space. Then, transform this 3-D RGB space into a 2-D space as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270866/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270867/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270868/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270869/image.png)
where ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270870/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270870/image.png)
After transformation, any pixels having a neutral color will be clustered among (0,0) in the u-v space. For each rain pixel detected above, transform their RGB values into the u-v space to form a 2-D vector(i.e., the Euclidean distance to the origin of the u-v space) is larger than a pre-set value 0.08,
is detected as a mis-detected rain pixel.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270866/image.png)
I have written the following code to represent the image in 3-D RGB space.
I=imread('inputRain.png');
R = I(:,:,1);
G = I(:,:,2);
B = I(:,:,3);
But, I cant convert this to the 2D vector space. I dont know how to implement these equations. Can anybody help me ?
2 个评论
Adam
2020-2-10
What do you mean by not getting 'the output'?
What data type is your image? Is it uint8 or floating point? I don't know if it matters for that equation, but since you are doing a division I would imagine they need to be floating point. If so the range of each colour channel should be 0-1.
采纳的回答
Image Analyst
2020-2-10
Did you try
R = double(I(:,:,1));
G = double(I(:,:,2));
B = double(I(:,:,3));
C = (R + G + B) / 3;
u = (2*C - G - B) ./ C;
term1 = (C - G) ./ C;
term2 = (C - B) ./ C;
v = max(cat(3, term1, term2), [], 3)
I don't know what " is detected as a mis-detected rain pixel." means. But you can do thresholding, like
binaryImageu = u > 0.08;
binaryImagev = v > 0.08;
7 个评论
Image Analyst
2020-2-12
"I want the RGB values for each pixel in an image" <=== You have that. That's what those variables are. If you want them in a CSV file, see attached demo.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!