finding the closest value

1 view (last 30 days)
FIR
FIR on 29 Nov 2012
i have valued as val(:,:,1) 8x8 matrix,,,,,,,,,,,,val(:,:,192)8x8 matrix
now i want to check which all values are nearby ,at a difference of 5 and for that we have to find mean value
suppose val(:,:,1) has mean value of 145.23 and val(:,:,56) has mean of 149.10and val(:,:,103) has mean of 143.05 for all these three we have to find the mean,and so on
please help
  3 Comments
Jan
Jan on 29 Nov 2012
So actually you are talking about the 3D array val(:,:,n) but you have calculated the mean values already, such that you operate on a vector? Does this mean, that the thread http://www.mathworks.com/matlabcentral/answers/55028-finding-mean-for-values is solved already? If so, please mark mark this thread correspondingly.
I still cannot guess, what "val(:,:,1) 8x8 matrix,,,,,,,," exactly means. The notation [8 x 8 x N] is common in Matlab, and a Matlab command as "rand(8, 8, n)" would be clear also.
Image Analyst
Image Analyst on 29 Nov 2012
I know FIR deals with images so maybe val is a color image that is a moving average window, like he's scanned it with a 8x8 window to get the average. But usually windows are an odd number so you don't have a shift of the image in the filtered image vs. the original image like you would for an even window size. But anyway, that's the only thing I can figure out when he says "val(:,:,1) has mean value of 145.23" because an array element by itself can't have an average - it has only its value - so it must be the average of a group of elements. But then I don't know what he means by the mean of all three. Maybe he means (145.23+149.10+143.05)/3 or maybe he wants a weighted average like rgb2gray calculates. But he already knows how to do those things. This question is not clearly explained.

Sign in to comment.

Answers (1)

Jan
Jan on 29 Nov 2012
Are you searching for a k-means algorithm? If so, ask your favorite search engine, search in this forum and the FileExchange also.

Community Treasure Hunt

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

Start Hunting!