MATLAB Answers

0

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

Aishwarya Jayachandran さんによって質問されました 2019 年 10 月 19 日
最新アクティビティ Divya Gaddipati さんによって 回答されました 2019 年 10 月 21 日
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

  2 件のコメント

David Hill
2019 年 10 月 19 日
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.
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

サインイン to comment.

1 件の回答

回答者: Divya Gaddipati 2019 年 10 月 21 日

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

  0 件のコメント

サインイン to comment.



Translated by