How to locate an image inside of a larger image in Matlab?











up vote
-2
down vote

favorite












https://i.stack.imgur.com/noHPu.png Waldo



https://i.stack.imgur.com/tKlMM.jpg wheresWaldo



I need to create a program that will find the image of Waldo in the background image.



I am only allowed to use length, size, imread, and the image functions.



So far, I have taken the first pixel from the Waldo image and searched the wheresWaldo image for the same R G B values as the first pixel in the Waldo image. I got a list of points with the same values. However, I am not sure which point is the one that pertains to Waldo. I know that the next step is to scan from each point and see if the surrounding pixels are the same as the one in the Waldo image, but I am not sure how to implement this.



Here is what I have so far:



[row,column,layer] = size(Waldo);
[row_,column_,layer_] = size(wheresWaldo);


counter = 0;
for i = 1:1:row_
for j = 1:1:column_
for k = 1:1:layer_
if wheresWaldo(i,j,1) == Waldo(1,1,1) && wheresWaldo(i,j,2) == Waldo(1,1,2) && wheresWaldo(i,j,3) == Waldo(1,1,3)
valid = 1;
counter = counter + 1;
ivals(counter) = i;
jvals(counter) = j;
end
end
end
end









share|improve this question




















  • 1




    This is the same as the question you asked (and deleted) yesterday, and it's still too broad, you're still just asking us to do your assignment for you; albeit you've not phrased it so explicitly! What specific issue have you got with this completely uncommented code? How are you unsure if this code works (the objective seems easily checkable)? It's still not clear what the "no implied loops like :" condition means, as that's not an implied loop. Please edit your question instead of asking a new one, and clarify all of these points.
    – Wolfie
    Nov 10 at 19:51












  • Have you traced your program in the debugger? Where is it going wrong? Have you tried executing it on a small window of the overall image? Does it terminate then?
    – beaker
    Nov 10 at 20:54










  • Hi Beaker. I went ahead and updated my post. If you could take a look, I would appreciate it. I made the problem I am having more specific and the code I have now is updated and works.
    – Andrew J Padilla
    Nov 11 at 0:11










  • You've now found a pixel wheresWaldo(i, j, :) that matches the top-left pixel of Waldo. (btw, you could implement that long if statement with isequal.) Before the edit you had another double loop to iterate over all elements of Waldo and match them to the current location in wheresWaldo. You need that loop.
    – beaker
    Nov 11 at 17:41

















up vote
-2
down vote

favorite












https://i.stack.imgur.com/noHPu.png Waldo



https://i.stack.imgur.com/tKlMM.jpg wheresWaldo



I need to create a program that will find the image of Waldo in the background image.



I am only allowed to use length, size, imread, and the image functions.



So far, I have taken the first pixel from the Waldo image and searched the wheresWaldo image for the same R G B values as the first pixel in the Waldo image. I got a list of points with the same values. However, I am not sure which point is the one that pertains to Waldo. I know that the next step is to scan from each point and see if the surrounding pixels are the same as the one in the Waldo image, but I am not sure how to implement this.



Here is what I have so far:



[row,column,layer] = size(Waldo);
[row_,column_,layer_] = size(wheresWaldo);


counter = 0;
for i = 1:1:row_
for j = 1:1:column_
for k = 1:1:layer_
if wheresWaldo(i,j,1) == Waldo(1,1,1) && wheresWaldo(i,j,2) == Waldo(1,1,2) && wheresWaldo(i,j,3) == Waldo(1,1,3)
valid = 1;
counter = counter + 1;
ivals(counter) = i;
jvals(counter) = j;
end
end
end
end









share|improve this question




















  • 1




    This is the same as the question you asked (and deleted) yesterday, and it's still too broad, you're still just asking us to do your assignment for you; albeit you've not phrased it so explicitly! What specific issue have you got with this completely uncommented code? How are you unsure if this code works (the objective seems easily checkable)? It's still not clear what the "no implied loops like :" condition means, as that's not an implied loop. Please edit your question instead of asking a new one, and clarify all of these points.
    – Wolfie
    Nov 10 at 19:51












  • Have you traced your program in the debugger? Where is it going wrong? Have you tried executing it on a small window of the overall image? Does it terminate then?
    – beaker
    Nov 10 at 20:54










  • Hi Beaker. I went ahead and updated my post. If you could take a look, I would appreciate it. I made the problem I am having more specific and the code I have now is updated and works.
    – Andrew J Padilla
    Nov 11 at 0:11










  • You've now found a pixel wheresWaldo(i, j, :) that matches the top-left pixel of Waldo. (btw, you could implement that long if statement with isequal.) Before the edit you had another double loop to iterate over all elements of Waldo and match them to the current location in wheresWaldo. You need that loop.
    – beaker
    Nov 11 at 17:41















up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











https://i.stack.imgur.com/noHPu.png Waldo



https://i.stack.imgur.com/tKlMM.jpg wheresWaldo



I need to create a program that will find the image of Waldo in the background image.



I am only allowed to use length, size, imread, and the image functions.



So far, I have taken the first pixel from the Waldo image and searched the wheresWaldo image for the same R G B values as the first pixel in the Waldo image. I got a list of points with the same values. However, I am not sure which point is the one that pertains to Waldo. I know that the next step is to scan from each point and see if the surrounding pixels are the same as the one in the Waldo image, but I am not sure how to implement this.



Here is what I have so far:



[row,column,layer] = size(Waldo);
[row_,column_,layer_] = size(wheresWaldo);


counter = 0;
for i = 1:1:row_
for j = 1:1:column_
for k = 1:1:layer_
if wheresWaldo(i,j,1) == Waldo(1,1,1) && wheresWaldo(i,j,2) == Waldo(1,1,2) && wheresWaldo(i,j,3) == Waldo(1,1,3)
valid = 1;
counter = counter + 1;
ivals(counter) = i;
jvals(counter) = j;
end
end
end
end









share|improve this question















https://i.stack.imgur.com/noHPu.png Waldo



https://i.stack.imgur.com/tKlMM.jpg wheresWaldo



I need to create a program that will find the image of Waldo in the background image.



I am only allowed to use length, size, imread, and the image functions.



So far, I have taken the first pixel from the Waldo image and searched the wheresWaldo image for the same R G B values as the first pixel in the Waldo image. I got a list of points with the same values. However, I am not sure which point is the one that pertains to Waldo. I know that the next step is to scan from each point and see if the surrounding pixels are the same as the one in the Waldo image, but I am not sure how to implement this.



Here is what I have so far:



[row,column,layer] = size(Waldo);
[row_,column_,layer_] = size(wheresWaldo);


counter = 0;
for i = 1:1:row_
for j = 1:1:column_
for k = 1:1:layer_
if wheresWaldo(i,j,1) == Waldo(1,1,1) && wheresWaldo(i,j,2) == Waldo(1,1,2) && wheresWaldo(i,j,3) == Waldo(1,1,3)
valid = 1;
counter = counter + 1;
ivals(counter) = i;
jvals(counter) = j;
end
end
end
end






matlab image-processing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 0:06

























asked Nov 10 at 19:30









Andrew J Padilla

23




23








  • 1




    This is the same as the question you asked (and deleted) yesterday, and it's still too broad, you're still just asking us to do your assignment for you; albeit you've not phrased it so explicitly! What specific issue have you got with this completely uncommented code? How are you unsure if this code works (the objective seems easily checkable)? It's still not clear what the "no implied loops like :" condition means, as that's not an implied loop. Please edit your question instead of asking a new one, and clarify all of these points.
    – Wolfie
    Nov 10 at 19:51












  • Have you traced your program in the debugger? Where is it going wrong? Have you tried executing it on a small window of the overall image? Does it terminate then?
    – beaker
    Nov 10 at 20:54










  • Hi Beaker. I went ahead and updated my post. If you could take a look, I would appreciate it. I made the problem I am having more specific and the code I have now is updated and works.
    – Andrew J Padilla
    Nov 11 at 0:11










  • You've now found a pixel wheresWaldo(i, j, :) that matches the top-left pixel of Waldo. (btw, you could implement that long if statement with isequal.) Before the edit you had another double loop to iterate over all elements of Waldo and match them to the current location in wheresWaldo. You need that loop.
    – beaker
    Nov 11 at 17:41
















  • 1




    This is the same as the question you asked (and deleted) yesterday, and it's still too broad, you're still just asking us to do your assignment for you; albeit you've not phrased it so explicitly! What specific issue have you got with this completely uncommented code? How are you unsure if this code works (the objective seems easily checkable)? It's still not clear what the "no implied loops like :" condition means, as that's not an implied loop. Please edit your question instead of asking a new one, and clarify all of these points.
    – Wolfie
    Nov 10 at 19:51












  • Have you traced your program in the debugger? Where is it going wrong? Have you tried executing it on a small window of the overall image? Does it terminate then?
    – beaker
    Nov 10 at 20:54










  • Hi Beaker. I went ahead and updated my post. If you could take a look, I would appreciate it. I made the problem I am having more specific and the code I have now is updated and works.
    – Andrew J Padilla
    Nov 11 at 0:11










  • You've now found a pixel wheresWaldo(i, j, :) that matches the top-left pixel of Waldo. (btw, you could implement that long if statement with isequal.) Before the edit you had another double loop to iterate over all elements of Waldo and match them to the current location in wheresWaldo. You need that loop.
    – beaker
    Nov 11 at 17:41










1




1




This is the same as the question you asked (and deleted) yesterday, and it's still too broad, you're still just asking us to do your assignment for you; albeit you've not phrased it so explicitly! What specific issue have you got with this completely uncommented code? How are you unsure if this code works (the objective seems easily checkable)? It's still not clear what the "no implied loops like :" condition means, as that's not an implied loop. Please edit your question instead of asking a new one, and clarify all of these points.
– Wolfie
Nov 10 at 19:51






This is the same as the question you asked (and deleted) yesterday, and it's still too broad, you're still just asking us to do your assignment for you; albeit you've not phrased it so explicitly! What specific issue have you got with this completely uncommented code? How are you unsure if this code works (the objective seems easily checkable)? It's still not clear what the "no implied loops like :" condition means, as that's not an implied loop. Please edit your question instead of asking a new one, and clarify all of these points.
– Wolfie
Nov 10 at 19:51














Have you traced your program in the debugger? Where is it going wrong? Have you tried executing it on a small window of the overall image? Does it terminate then?
– beaker
Nov 10 at 20:54




Have you traced your program in the debugger? Where is it going wrong? Have you tried executing it on a small window of the overall image? Does it terminate then?
– beaker
Nov 10 at 20:54












Hi Beaker. I went ahead and updated my post. If you could take a look, I would appreciate it. I made the problem I am having more specific and the code I have now is updated and works.
– Andrew J Padilla
Nov 11 at 0:11




Hi Beaker. I went ahead and updated my post. If you could take a look, I would appreciate it. I made the problem I am having more specific and the code I have now is updated and works.
– Andrew J Padilla
Nov 11 at 0:11












You've now found a pixel wheresWaldo(i, j, :) that matches the top-left pixel of Waldo. (btw, you could implement that long if statement with isequal.) Before the edit you had another double loop to iterate over all elements of Waldo and match them to the current location in wheresWaldo. You need that loop.
– beaker
Nov 11 at 17:41






You've now found a pixel wheresWaldo(i, j, :) that matches the top-left pixel of Waldo. (btw, you could implement that long if statement with isequal.) Before the edit you had another double loop to iterate over all elements of Waldo and match them to the current location in wheresWaldo. You need that loop.
– beaker
Nov 11 at 17:41



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242655%2fhow-to-locate-an-image-inside-of-a-larger-image-in-matlab%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242655%2fhow-to-locate-an-image-inside-of-a-larger-image-in-matlab%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values