# I am not getting the correct value for rblush in this code. here, red is a matrix consisting of only the r of rcb values of an image. If the value of red_pixel is greater than 200, i want to add the pixel values in rblush but im getting the wrong val

1 view (last 30 days)
Aishwarya Jayachandran on 19 Oct 2019
for x=1:rows
for y=1:columns
red_pixel= red(x,y);
if(red_pixel>=200)
if(red_pixel> rmean)
blush= blush+1;
rblush =sum(red_pixel);
end
end
end
end
%the value of rblush should be a big number but it only goes upto 255, how do i modify the code to achieve this

David Hill on 19 Oct 2019
I don't understand what you are trying to do. You need to explain more. What is rmean? What is blush (a counter)? What do you want to do with all the pixels >=200? Tell us exactly what you want done.
Aishwarya Jayachandran on 19 Oct 2019
rmean is the mean of all the red pixels over 150 in the image.
Im using blush to obtain the number of pixels where that satisfies both the conditions of being greater than rmean and 200
i would like to get the sum of all the pixel values >= 200.
red(x,y) is a matrix that cointains the red pixels of an image
PS: ive made a modified the code a little bit and this is what it says now
for x=1:rows
for y=1:columns
if(red(x,y)>rmean)
rblush= sum(red(red >= 200));
blush= blush+1;
This takes a really really long time to compute .
Any way this issue can be rectified

Divya Gaddipati on 21 Oct 2019
Since “red” is your red-channel image, you can directly find the pixel values that are greater than 200 and “rmean” in the following way:
pxls = red(red > 150 & red >= 200); % “mask” will have the required pixel values
pixels_sum = sum(pxls); % required sum which is "rblush" in your code
no_of_pixels = length(pxls) % number of required pixels which is "blush" in your case