Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:12:53+00:00 2026-06-18T11:12:53+00:00

as a part of my homework i need to implement this pattern matching. the

  • 0

as a part of my homework i need to implement this pattern matching.
the goal is to “Detect as many of the 0’s (zeros) as you can in image coins4.tif.”

i was given the NGC function. and i need to use it

this is my main.m file

Image = readImage('coins4.tif');
Pattern = readImage('zero.tif');
showImage(Image);
showImage(Pattern);
message = sprintf('Pattern matching Normalized Correlation');
PatternMatching(Image , Pattern);
uiwait(msgbox(message,'Done', 'help'));
close all

this is my PatternMatching function.

function [ output_args ] = PatternMatching( Image , Pattern )
% Pattern matching – Normalized Correlation
% Detect as many of the 0's (zeros) as you can in image coins4.tif.
% Use the 0 of the 10 coin as pattern.
% Use NGC_pm and find good threshold. Display original image with? detected regions marked using drawRect.

% NGCpm(im,pattern);
% drawRect(rectCoors,color);
% rectCoors = [r0,c0,rsize,csize]  - r0,c0 = top-left corner of rect.
%             rsize = number of rows, csize = number of cols
%
% color = an integer >=1 representing a color in the color wheel
%                   (curerntly cycles through 8 different colors

showImage(Image);
hold on
res = NGCpm(Image, Pattern);

 for i = 1:size(res,1)
     for j = 1:size(res,2)
         if res(i,j) > 0.9999
             drawRect([i j size(Pattern,1) size(Pattern,2)], 5)
         end
     end
 end

end

this is the Given NGCpm.m file

function res=NGC_PM(im,pattern)
[n m]=size(pattern);
[im_row,im_col]=size(im);
if ~(var(pattern(:))==0)
     res = normxcorr2(pattern, im);
     res=res(n:im_row,m:im_col);   
else
    res=zeros(size(im)-size(pattern)+1);
end;
 res = 1-abs(res);  % res = abs(res);

this is the pattern i’m trying to find and the results, i’m getting

i’m trying to find as many “Zeros” as possiable using the zero pattern of the coin 10.

i’m tryingto understand if there is something wrong with my algorithm in the PatternMatching function. since the NGCpm function is already given to me, all i need to do is just loop of the best threshold ,correct?

or do i need to blur the image or the pattern?

this is the pattern i'm trying to find

this is the image and the results

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:12:54+00:00Added an answer on June 18, 2026 at 11:12 am

    this is the fixed version of this function.

    function [ output_args ] = patternMatching( Image , Pattern )
    % Pattern matching – Normalized Correlation
    % Detect as many of the 0's (zeros) as you can in image coins4.tif.
    % Use the 0 of the 10 coin as pattern.
    % Use NGC_pm and find good threshold. Display original image with? detected regions marked using drawRect.
    
    % NGCpm(im,pattern);
    % drawRect(rectCoors,color);
    % rectCoors = [r0,c0,rsize,csize]  - r0,c0 = top-left corner of rect.
    %             rsize = number of rows, csize = number of cols
    %
    % color = an integer >=1 representing a color in the color wheel
    %                   (curerntly cycles through 8 different colors
    
    showImage(Image);
    hold on
    res = 1-NGCpm(Image, Pattern);
    normalized_corellation = uint8(255*res/max(max(res)));
    res_thresh = thresholdImage(normalized_corellation,100);
     for i = 1:size(res_thresh,1)
         for j = 1:size(res_thresh,2)
             if res_thresh(i,j) > 0
                 drawRect([i j size(Pattern,1) size(Pattern,2)], 5)
             end
         end
     end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so this is part of my homework assignment. need some help with it. my
This is homework, but I need a nudge. I can't find how to sort
I need to implement a digraph(Directed graph) in c++ as part of a homework
This is part of a homework assignment so my goal is to understand why
As part of a homework assignment I need to concatenate certain values in an
This is part of a homework assignment. I've got several questions asking find the
I am trying to learn TDD and this is part of my homework I
(this is indirectly a part of a much larger homework assignment) I have something
As part of my homework, I need to make a program that requires user
I have this homework problem where I need to use regex to remove every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.