how to compare the value of a pixel with all other pixel?

 採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 10 月 28 日

0 投票

M = randi(10,40,30);
uM = unique(M);
out = [uM, histc(M(:),uM)];

3 件のコメント

sheno39
sheno39 2013 年 10 月 28 日
編集済み: sheno39 2013 年 10 月 28 日
if true
I=im2double(imread('texture1.jpg'));
imshow(I);
%S=uint8(rgb2gray(I));
S=rgb2gray(I);
%S=I;
imshow(S),figure;
M=[1 1 1;1 1 1;1 1 1]./9;
A=(exp(-((S-conv2(S,M,'same')).^2)./18));
I=(1/2*pi*9).*A;
D = padarray(I,[1 1],0,'both');
s = size(I);
N = padarray(reshape(1:numel(I),s),[1 1],0,'both');
pt = [1 1 1;1 0 1;1 1 1] > 0;
s1 = s+2;
out = zeros(s);
for i=2:s1(1)-1
for j=2:s1(2)-1
D1 = D(i-1:i+1,j-1:j+1);
K = N(i-1:i+1,j-1:j+1);
K = K(pt);
[~,i0] = max(D1(pt));
out(i-1,j-1) = K(i0);
end
end
end
sir here i attached my coding. The 'out' variable stores the location of maximum pixel. The 'I' variable stores the intensity value.
i need to do the following: take the first location value(for eg: 320) in the 'out' variable and find the corresponding intensity value in the 'I' matrix. then compare that intensity value with all other values in the 'I' matrix. If any equal value available, have to replace the corresponding similar values locations by the first value. (ie. 320)
Can u help me sir?
Image Analyst
Image Analyst 2013 年 10 月 28 日
You forgot to attach your texture1.jpg image. Don't make it hard for us to help you. Make it easy for us to help you by attaching your image.
sheno39
sheno39 2013 年 10 月 28 日

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

その他の回答 (2 件)

Jos (10584)
Jos (10584) 2013 年 10 月 28 日

0 投票

You question is a little unclear. But, see
help unique
M = ceil(10*rand(40,30)) % pixel image
uM = unique(M) ;
% and use it like this
tf = M==uM(k)
[r,c] = find(tf)

1 件のコメント

sheno39
sheno39 2013 年 10 月 28 日
sir i have to compare each pixel with all other pixels and if any pixels having equal values i have to increament the count.

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

sheno39
sheno39 2013 年 10 月 28 日

0 投票

i have attached my image here

カテゴリ

タグ

質問済み:

2013 年 10 月 28 日

回答済み:

2013 年 10 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by