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

6 vues (au cours des 30 derniers jours)
wissa amer
wissa amer le 11 Juin 2013
Commenté : Image Analyst le 10 Jan 2019
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
Range_Image=rgb2gray(imread('data.jpg'));
[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 commentaires
viswanath reddy
viswanath reddy le 10 Jan 2019
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
Image Analyst le 10 Jan 2019
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.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 11 Juin 2013
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 commentaires
Image Analyst
Image Analyst le 11 Juin 2013
Entisar, why do you want to do this thing? What will it accomplish for you?
wissa amer
wissa amer le 12 Juin 2013
I AM WORK TO DO WAY TO IMAGE COMPRESSION

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by