how to select the parts in image that match the image i have in my database?

i select certain part of an image and i its features in data base and then i use different images so i want to find out if features are in them or not

 Accepted Answer

What do you mean by features? Do you mean that your "certain part of an image ... in data base" is contained as a sub-image in the "different images"? If so, you can use normxcorr2 (let me know if you want a demo). Otherwise you just have to compare feature vectors and you can do a weighted sum of differences. Or maybe you mean CBIR, like "show me all beach scenes" or "Show me photos of babies" or something like that.

10 Comments

"features" i want to know if the images contain the part of image i had saved in my database .so i said if i can get it feature and the matching it with my images.
and demo of normxcorr2 is useful .
i don't familiar with CBIR what do mean of it it technique or what?
CBIR is "Content Based Image Retrieval" and is the name given to queries like I gave examples for.
Below is the demo of normxcorr2():
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 2, 1);
imshow(rgbImage, []);
axis on;
title('Original Color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
smallSubImage = imcrop(rgbImage, [192 82 60 52]);
subplot(2, 2, 2);
imshow(smallSubImage, []);
axis on;
title('Template Image to Search For', 'FontSize', fontSize);
% Search the red channel for a match.
correlationOutput = normxcorr2(smallSubImage(:,:,1), rgbImage(:,:,1));
subplot(2, 2, 3);
imshow(correlationOutput, []);
title('Correlation Output', 'FontSize', fontSize);
[maxCorrValue, maxIndex] = max(abs(correlationOutput(:)));
[ypeak, xpeak] = ind2sub(size(correlationOutput),maxIndex(1));
corr_offset = [(xpeak-size(smallSubImage,2)) (ypeak-size(smallSubImage,1))];
subplot(2, 2, 4);
imshow(rgbImage);
hold on;
rectangle('position',[corr_offset(1) corr_offset(2) 50 50],...
'edgecolor','g','linewidth',2);
title('Template Image Found in Original Image', 'FontSize', fontSize);
my image(in my database) -lets called it target -is so small and the images contain many of my target image and i want to select all targets in the images. can this CBIR do that.
example
my target image is circle and my images contains many of circles so i want to select all circles in the image
Yes. That is the whole concept of CBIR. For example, find me all scenes in a movie with the sun in it. Or find me all scenes with a tree and a person. It is rapidly getting very sophisticated. Fast progress is being made. At the last Electronic Imaging meeting I saw some very impressive results, but there are still challenges of course.
Sorry but this code cant select the other Onion in the image even though it has the same color and Features
{Sorry for being late to respond but due to busy at work.And The time difference }
Correct. It was designed specifically not to do that -- not to produce false positives. The other onion is not the same even though it looks somewhat similar.
i want to select the other onion also and similar to it Features
Then you're wanting to get into the field of CBIR. I'm not an expert in that field. There are whole conferences on it though, plus plenty of literature. It's a growing field right now with the explosion of imagery available now and people wanting to search stock databases, the web, and videos. You will be able to find lots of people in that field without too much trouble and some of them may help you. For example, a web search on CBIR and section 19.4 of VisionBib.
thanks a lot "Image Analyst" and i will search for it on web
Thank you for your interest.
If we're done then please mark it as Accepted.

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!