MATLAB Answers

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 view (last 30 days)
radha on 20 Feb 2014
Commented: radha on 20 Feb 2014
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');
%hist(i,j,a(i,j)) = 1;
for i=1:r
for j=1:c
h1 = lbp(radon(double(ca{i,j})),1,8,mapping,'h');
%h2 = lbp(radon(double(ca{6,5})),1,8,mapping,'h');
%disp('Histo Plot');
title('LBP of 8 and 1');
sumHist = lbp(radon(double(ca{1,1})),1,8,mapping,'h');
for i=1:r
for j=1:c
%title('Final Histogram');
[ro col]=size(sumHist);
disp('Columns of Sketch Image');
% sumHist=sumHist/size(Image,1)/size(Image,2);
%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
  1 Comment
radha on 20 Feb 2014
I have posted my entire code here but it is displaying all together... Please check it and help me out with the same...

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!