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

5 ビュー (過去 30 日間)
wissa amer
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
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 件のコメント
viswanath reddy
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
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
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 件のコメント
Image Analyst
Image Analyst 2013 年 6 月 11 日
Entisar, why do you want to do this thing? What will it accomplish for you?
wissa amer
wissa amer 2013 年 6 月 12 日
I AM WORK TO DO WAY TO IMAGE COMPRESSION

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by