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

2 ビュー (過去 30 日間)
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
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.
Aishwarya Jayachandran
Aishwarya Jayachandran 2019 年 10 月 19 日
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

サインインしてコメントする。

回答 (1 件)

Divya Gaddipati
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

カテゴリ

Help Center および File ExchangeMarine and Underwater Vehicles についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by