Please help me what should I do so as to differentiate between the match and non-match between the images in sketch based image matching system. I am comparing histograms of the colour image and sketch image using chi-square distance. I am getting mi

1 次查看(过去 30 天)
clear all; clc; Image=imread('D:\Project\CUHK_testing_sketch\sketch\f1-002-01-sz1.jpg'); %Image=im2double(Image); %Image=imresize(Image,[256 256]); [rows columns]=size(Image);
blockSizeR = 65; % Rows in block. blockSizeC = 65; % Columns in block. % Figure out the size of each block in rows. % Most will be blockSizeR but there may be a remainder amount of less than that. wholeBlockRows = floor(rows / blockSizeR); blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)]; % Figure out the size of each block in columns. wholeBlockCols = floor(columns / blockSizeC); blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)]; % Create the cell array, ca. % Each cell (except for the remainder cells at the end of the image) % in the array contains a blockSizeR by blockSizeC by 3 color array. % This line is where the image is actually divided up into blocks.
ca = mat2cell(Image, blockVectorR, blockVectorC);
disp('ca'); disp(ca); % Now display all the blocks. plotIndex = 1; numPlotsR = size(ca, 1); %disp(numPlotsR); numPlotsC = size(ca, 2); %disp(numPlotsC); for r = 1 : numPlotsR for c = 1 : numPlotsC fprintf('plotindex = %d, c=%d, r=%d\n', plotIndex, c, r); % Specify the location for display of the image. subplot(numPlotsR, numPlotsC, plotIndex); % Extract the numerical array out of the cell Block = ca{r,c}; imshow(Block); % Could call imshow(ca{r,c}) [rowsB columnsB] = size(Block); % Make the caption the block number. caption = sprintf('Block #%d of %d\n%d rows by %d columns', ... plotIndex, numPlotsR*numPlotsC, rowsB, columnsB); title(caption); drawnow; % Increment the subplot to the next location. plotIndex = plotIndex + 1; end end % Display the original image in the upper left. subplot(4, 6, 1); imshow(Image),figure; title('Original Image'); %------------------------------------------------------------------------------------------------------------------ %Radon transform
theta=0:90; for i=1:r for j=1:c [R,xp]=radon(double(ca{i,j}),theta); %figure,imshow(R,[],'XData',xp([1 end]),'YData',[90 0]); %axis xy; %axis on; %xlabel('\rho'),ylabel('\theta'); end end
%Transform display
imshow(R,[],'XData',xp([1 end]),'YData',[90 0]),figure(2);
title('Radon transform');
axis xy;
axis on;xlabel('\rho'),ylabel('\theta');
%------------------------------------------------------------------------------------------------------------------------
%LRBP
mapping=getmapping(8,'u2');
%hist(i,j,a(i,j)) = 1;
for i=1:r
for j=1:c
figure(3);
h1 = lbp(radon(double(ca{i,j})),1,8,mapping,'h');
%h2 = lbp(radon(double(ca{6,5})),1,8,mapping,'h');
%hist(h1);
%disp('Histo Plot');
%disp(h1);
subplot(1,1,1);
stem(h1);
%imhist(h1);
title('LBP of 8 and 1');
%subplot(2,1,1),stem(h2);
%disp(h1);
end
end
sumHist = lbp(radon(double(ca{1,1})),1,8,mapping,'h');
for i=1:r
for j=1:c
sumHist=sumHist+lbp(radon(double(ca{i,j})),1,8,mapping,'h');
end
end
%subplot(1,1,1);
%title('Final Histogram');
HiS=imhist(sumHist);
%stem(sumHist);
[ro col]=size(sumHist);
disp('Columns of Sketch Image');
disp(col);
% sumHist=sumHist/size(Image,1)/size(Image,2);
%colorImage=imread('D:\Project\CUHK_testing_photo\photo\f1-001-01.jpg');
%grayImage=rgb2gray(double(colorImage));
%imhist(grayImage,256);
%title('Color Gray hist');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% colorImage=imread('D:\Project\CUHK_testing_photo\photo\f1-001-01.jpg'); %colorImage=im2double(colorImage); %colorImage=imresize(colorImage,[256 256]); grayImage=rgb2gray(double(colorImage)); Hi=imhist(grayImage); %title('Color Gray hist'); [rl colm]=size(grayImage); disp('columns of color Image'); disp(colm); %H=H/size(colorImage,1)/size(colorImage,2); %Matching one imge
distance = pdist2(Hi,HiS,'chisq'); disp(distance); mi=min(distance); %disp(mi); mif=min(mi); disp('minimun'); disp(mif);
ms=max(max(distance)); disp('maximum'); disp(ms);
if mif==0 && ms<0 msgbox('Person not present in database'); else msgbox('Person present in database'); end
%if mif==0 && ms<0 % msgbox('Person not available in database'); %end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by