CBIR

7 views (last 30 days)
Mangesh Dhantole
Mangesh Dhantole on 16 Nov 2011
hey guys i am beginner in image processing!!! I have a little problem in writing CBIR code please help me !!!!! I have written a matlab code which extract a feature of Query image in the form of matrix of 1x256x4 order and I have also created a database of images (a .mat file)which has same feature matrix of too many images!!!!! My problem is i am not getting how do I compare these two metrics for image restoration !!!! I found that many programmer use concept of Euclidean distance for it but I am not getting how to implement it in my case !!!
  2 Comments
David Young
David Young on 16 Nov 2011
I can't see how this will lead to image restoration. Do you mean image retrieval?
You will need to give more details of your feature matrix. Why is it 1x256x4 rather than simply 256x4? What does a given element represent?
Mangesh Dhantole
Mangesh Dhantole on 17 Nov 2011
thank you David Young for your reply !!!!
I have to write a code for retrieval of Images which has same feature as Query.......I am using R,G,B,I content of image for extracting feature of image an 1x256x1 shows R content,1x256x2 shows G content,1x256x3 shows B content,1x256x4 shows I content of image this matrix is similar to any matrix of colour image only difference is that due to loop which I am using in my program I am getting it in form of 1x256x4..... if it has some problem I can change that to any order my making some changes in my code.........my code is as follow
Im=imread('Pic.jpg');
Im=imresize(Im,[256 256]);
x1=im2double(rgb2gray(Im));
x2=im2double(Im(:,:,1));
x3=im2double(Im(:,:,2));
x4=im2double(Im(:,:,3));
I=zeros(1,256);
R=zeros(1,256);
G=zeros(1,256);
B=zeros(1,256);
for j=1:16
for i=1:16
sum1=0;sum2=0;sum3=0;sum4=0;
for k=j*16-15:j*16
for l=i*16-15:i*16
sum1= x1(l,k)+sum1;
sum2= x2(l,k)+sum2;
sum3= x3(l,k)+sum3;
sum4= x4(l,k)+sum4;
end
end
I(1)=sum1/256;
R(1)=sum2/256;
G(1)=sum3/256;
B(1)=sum4/256;
end
end
for p=1:256
data(1,p,1)={R(1,p)};
data(1,p,2)={G(1,p)};
data(1,p,3)={B(1,p)};
data(1,p,4)={I(1,p)};
end
while performing same operation on any N image I am using data(N,p,1:4).......

Sign in to comment.

Answers (1)

Yunas Qazi
Yunas Qazi on 2 Jan 2013
Edited: Yunas Qazi on 2 Jan 2013
[val idx]=sort(sqrt(sum((A-B).^2)));
It will calculate Euclidean Distance for you.
Val contains the difference Value
and Id contains the index value.
Consider A the QueryImage Feature Vector and B the Image From DB Feature Vector.

Community Treasure Hunt

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

Start Hunting!