# finding the closest value

2 views (last 30 days)
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
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.

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.

### Categories

Find more on Matrix Indexing in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by