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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 10월 28일
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?
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.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Jos (10584)
Jos (10584) 2013년 10월 28일
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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

태그

질문:

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