HOw to find similar pixels in 3x3 window

2 ビュー (過去 30 日間)
Rehan
Rehan 2015 年 6 月 4 日
コメント済み: Rehan 2015 年 6 月 4 日
Hi all, I have a question to ask,i have 3X3 window of an image such like image below. f(i,j) is center pixel ,so i want to find three most similar pixels except of center pixel in this 3X3 window,please help me regarding this. thanks
  4 件のコメント
Walter Roberson
Walter Roberson 2015 年 6 月 4 日
Most similar to each other, or most similar to the center pixel?
Rehan
Rehan 2015 年 6 月 4 日
most similar to each other

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

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 4 日
The set of pixels that are most similar to each other are the ones where (x2-x1)^2+(x3-x2)^2 is least. We can also order the pixels first because if x1<x2 and x2<x3 then x3 is less similar to x1 than x2 is to x1
pix = f(i-1:i+1,j-1:j+1); %entire window
pix = sort(pix(1:4,6:end)); %exclude center
pd2 = diff(pix).^2; %difference squared
ssq = pd2(1:end-1)+pd2(2:end); %sum of 2 squares
[minval, minidx] = min(ssq);
mean_wanted = mean(pix(minidx:minidx+2));
  1 件のコメント
Rehan
Rehan 2015 年 6 月 4 日
got it .Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by