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

 Accepted Answer

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

3 Comments

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?
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.

Sign in to comment.

More Answers (2)

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 Comment

sir i have to compare each pixel with all other pixels and if any pixels having equal values i have to increament the count.

Sign in to comment.

Tags

Asked:

on 28 Oct 2013

Answered:

on 28 Oct 2013

Community Treasure Hunt

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

Start Hunting!