Please help me out in rectifying the errors in implementing Content Based Image Retrieval System.

I have 56 images in a database.i want to display and coompare best five images with the query image using eucledian distance.the problem which i get is that the result doesnot show best five images instead its showing only one image which is the query image.my program is:
PROGRAM NO 1:
clc;
G=imread('n252.tif');
H = adapthisteq(G);
[rows cols]=size(G);
[c1,s1]=wavedec2(H,1,'db1');
%disp(c1);
X=c1;
figure,imshow(G);
%figure,imshow(H);
fileFolder=fullfile(matlabroot,'toolbox','images','imphoto');
dirOutput=dir(fullfile(fileFolder,'*.tif'));
fileNames={dirOutput.name}
n=numel(fileNames)
g=zeros(1,n);
for k = 1 : n
fileNames1=strcat('fullfile(fileFolder)',fileNames(k))
I = imread(fileNames{k});
J = adapthisteq(I);
J = imresize(J, [rows cols]);
[c2,s2]=wavedec2(J,1,'db1');
%disp(c2);
Y=c2;
%[rows1 cols1]=size(J);
E_distance = sqrt(sum((X-Y).^2));
g(1,k)=E_distance;
if g(1,k)==0
w=k;
end
%figure,imshow(I);
%figure,imshow(J);
end
disp(g);
%II=imread(fileNames{w});
%figure, imshow(II);
[sorted,IX] = sort(g);
bestFiveImages = IX(1:5);
for I = 1:length(bestFiveImages)
figure;imshow(imread(fileNames{bestFiveImages(I)}));
end
the error came as follows:
??? Error using ==> images\private\checkinput>check_attributes
Function ADAPTHISTEQ expected its first input argument, I,
to be two-dimensional.
Error in ==> images\private\checkinput at 37
check_attributes(A, attributes, function_name, variable_name, ...
Error in ==> adapthisteq>parseInputs at 411
checkinput(I, {'uint8' 'uint16' 'double'}, ...
Error in ==> adapthisteq at 155
[I, selectedRange, fullRange, numTiles, dimTile, clipLimit, numBins, ...
Error in ==> new at 18
J = adapthisteq(I,'clipLimit',0.02,'Distribution','rayleigh');
please help me out in rectifing these errors..
actualy i have done the same program but with different database.in that case the result came out but when i have changed the database the above problem persists..
the same program which is done by using different database is as follows(here the result came):
PROGRAM NO 2:
clc;
G=imread('lion1.jpg');
G1=rgb2gray(G);
H = adapthisteq(G1);
[rows cols]=size(G1);
[c1,s1]=wavedec2(H,1,'db1');
%disp(c1);
X=c1;
figure,imshow(G);
%figure,imshow(H);
fileFolder=fullfile(matlabroot,'toolbox','images','imda');
dirOutput=dir(fullfile(fileFolder,'*.jpg'));
fileNames={dirOutput.name}
n=numel(fileNames)
g=zeros(1,n);
for k = 1 : n
fileNames1=strcat('fullfile(fileFolder)',fileNames(k))
I = imread(fileNames{k});
I1=rgb2gray(I);
J = adapthisteq(I1);
J = imresize(J, [rows cols]);
[c2,s2]=wavedec2(J,1,'db1');
%disp(c2);
Y=c2;
%[rows1 cols1]=size(J);
E_distance = sqrt(sum((X-Y).^2));
g(1,k)=E_distance;
if g(1,k)==0
w=k;
end
%figure,imshow(I);
%figure,imshow(J);
end
disp(g);
%II=imread(fileNames{w});
%figure, imshow(II);
[sorted,IX] = sort(g);
bestFiveImages = IX(1:5);
for I = 1:length(bestFiveImages)
figure;imshow(imread(fileNames{bestFiveImages(I)}));
end
here in program no 2 no such error is coming.so i want to know what is the mistake in program no 1.the result is coming in program no 2 but in program no 1 no result is coming instead the errors are coming.though the two programs are same only the difference is that i have taken different databases in these two above mentioned programs..Thanks

댓글 수: 3

please help me @image analyst ,@walter roberson
The error says your image I is not 2 dimensional (grayscale) image. In second code you used rgb2gray before adapthisteq function:
I1=rgb2gray(I);
J = adapthisteq(I1);
yeah i know the error but how to rectify them?please help and i used rgb2gray in 2nd code because some of the images are coloured but i want gray image.thanks

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

 채택된 답변

adapthisteq() doesn't work with color images.
Anyway, there is no CBIR that I can see in your code. You're just comparing the intensities of the wavelet images. I could be wrong because I'm not a wavelet guy, but I don't think that will allow you to do things like "show me all pictures with a beach in them" or "show me all photos with a dog in them", etc.

댓글 수: 4

i have used this rgb2gray in the program no 1 but still the error comes..now the error shows:
??? Error using ==> rgb2gray>parse_inputs MAP must be a m x 3 array.
Error in ==> rgb2gray at 35 X = parse_inputs(varargin{:});
Error in ==> new3 at 3 G1=rgb2gray(G); >>
Evidently instead of just passing back the input image if it's already grayscale (like one might intuitively think), rgb2gray errors out. So to avoid that check how many color channels it has, and call it only if it's color, like Iman showed you.
thanks @Iman and @image analyst...yes it worked..actually there were coloured image in my database.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

2013년 5월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by