# Comparison between the values ​​of pixels in the image matrix

조회 수: 3 (최근 30일)
wissa amer 2013년 6월 11일
댓글: Image Analyst 2019년 1월 10일
This code to divide the image to Blocks After the divided we take the avrege of each block with size 4*4 pixel and store values in new matrix image called (a) Then we want to compare the value of each pixel in matrix (a) with all the other values of pixels in the same matrix when we find value equal another values in the same matrix put in other postion of those value zero. after that we store in the new image in first row we store the value of each pixel and in another row we store the number of pixel equals and its postion
if true
[m n]=size(Range_Image); Nbrx = floor(m./4);
Nbry = floor(n./4); Nd=1;
for i=1:Nbrx
for j=1:Nbry
Mat=Range_Image((i-1)*4+1:i*4,(j-1)*4+1:j*4);
sumpixel=sum(Mat(:));
avg=floor(sumpixel./16);
a(i,j)=avg;
%subplot(Nbrx,Nbry,Nd);
Nd=Nd+1;
end
end
figure(1),imshow(a,[])
count=0;
[x y]=size(a); Nbrx = floor(x);
Nbry = floor(y);
for i=1:Nbrx
for j=1:Nbry
a(i,j);
count=0;
if (a(i,j) ~= 0)
for z=1:Nbrx
for k=1:Nbry
if (a(i,j)==a(z,k))
count=count+1;
b(1,j)=a(i,j);
b(2,j)=count;
a(z,k)=0;
end
end
end
end
end
end
end
##### 댓글 수: 2없음 표시없음 숨기기
viswanath reddy 2019년 1월 10일
i want code for comparison of pixels in an image by considering a 3*3 matrix. for each pixel, a 3*3 matrix around the pixel should be considered and the pixel must be compared with both the diagonals of the considered 3*3 matrix, whether the pixel is greater than all the diagonal elements or not?
Image Analyst 2019년 1월 10일
I think you meant to post this as your own new question rather than to send this to wissa as a comment to her. Please do so and we'll answer there.

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

### 답변 (1개)

Image Analyst 2013년 6월 11일
I'm not sure I follow the grammar of this sentence: "Then we want to compare the value of each pixel in matrix (a) with all the other values of pixels in the same matrix when we find value equal another values in the same matrix put in other postion of those value zero. " I'm also not sure if you have a question or not - you didn't ask one. But I'd guess that it may be unlikely the average of one block will exactly equal the average of another block. Thus you will have to read an understand this FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
##### 댓글 수: 4이전 댓글 2개 표시이전 댓글 2개 숨기기
Image Analyst 2013년 6월 11일
Entisar, why do you want to do this thing? What will it accomplish for you?
wissa amer 2013년 6월 12일
I AM WORK TO DO WAY TO IMAGE COMPRESSION

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

### 카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by