Representing a pixel's color vector in 3D RGB space and transforming into 2D space

2 次查看(过去 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:
where
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.
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
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.
Aiswarya C B
Aiswarya C B 2020-2-10
I have a 2D matrix and if the pixel is detected as a rain pixel, I have to set the corresponding location of the matrix with value 0. By output, I mean that. I have an input .png image but I didn't convert that to uint8 or floating point type.

请先登录,再进行评论。

采纳的回答

Image Analyst
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
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!

Translated by