MATLAB Answers

0

How to find avergae of thresholded elements only from a matrix?

Asked by Tarunkishwor Yumnam on 20 Aug 2019
Latest activity Commented on by Tarunkishwor Yumnam on 21 Aug 2019
Accepted Answer by KSSV
I am trying to calculate average RGB of images with a uniform background. So I want to remove the background from the calculation. How do I select only elements belows above/below certain value (say <250) and calculate average of those only.

  2 Comments

@Tarunkishwor Yumnam: Please do not advertise questions in other threads. Imagine the clutter, if all users do this. Thanks.
Avg=mean2(your image (:));

Sign in to comment.

1 Answer

Answer by KSSV
on 20 Aug 2019
 Accepted Answer

Let A be your matrix......say you want values below a threshold val.
idx = A<val ;
themean = mean(A(idx)) ;