find an image in a big image

4 views (last 30 days)
Abdur Rahim
Abdur Rahim on 20 Feb 2014
Commented: Walter Roberson on 21 Feb 2014
I am trying to find a sample image patternC :
In my large image like :
To accomplish this task, i have coded this:
clc;
htm=vision.TemplateMatcher;
hmi = vision.MarkerInserter('Size', 10, ...
'Fill', true, 'FillColor', 'black', 'Opacity', 0.75);
% smallSubImage = fullfile(matlabroot, '\toolbox\images\imdemos\1.bmp');
% I = imread(smallSubImage);
I = imread('6.tif');
% Input image
I = I(:,:,:);
% Use grayscale data for the search
[rows, columns, numberOfColorChannels] = size(I);
if numberOfColorChannels == 3
I = rgb2gray(I);
if rows > 200 && columns > 200
I = I(1:rows,1:columns,:); % Crop all 3 channels.
end
else
if rows > 200 && columns > 200
I = I(1:rows,1:columns); % Crop single channel.
end
end
display(rows);
display(columns);
Igray = imread('patternC.tif');
[rows, columns, numberOfColorChannels] = size(Igray);
if numberOfColorChannels == 3
Igray = rgb2gray(Igray);
else
Igray = Igray(1:rows,1:columns); % Crop single channel.
end
% Use a second similar chip as the template
T = Igray;
% Find the [x y] coordinates of the chip's center
Loc=step(htm,Igray,T);
display(Loc);
display(NVALS);
display(NVALID);
% Mark the location on the image using Black disc
J = step(hmi, I, Loc);
imshow(T); title('Template');
figure; imshow(J); title('Marked target');
display('process completed');
But the output is:
The template is detected on the LEFT TOP corner(A Black Circle) of the image.
I am new in matlab. What is the matter here? Which things I have to take in mind?
  5 Comments
Abdur Rahim
Abdur Rahim on 21 Feb 2014
The Big image is really big here. The output window is just showing 25% view. So the black circle is looking small and asterisk like. Its a black circle I defined in my 2nd(& 3rd) line of code. And the quote was a mistake. It is black disk and I edited the question. Yes, I cannot see a white disc on a white paper.
Walter Roberson
Walter Roberson on 21 Feb 2014
How could the output possibly be that? The date of the page changes, the QR code goes away, the list of digits along the left side got replaced by a linear barcode ???

Sign in to comment.

Answers (0)

Categories

Find more on Display Image 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!