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
matlab image-processing
add a comment |
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
matlab image-processing
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 pixelwheresWaldo(i, j, :)
that matches the top-left pixel ofWaldo
. (btw, you could implement that longif
statement withisequal
.) Before the edit you had another double loop to iterate over all elements ofWaldo
and match them to the current location inwheresWaldo
. You need that loop.
– beaker
Nov 11 at 17:41
add a comment |
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
matlab image-processing
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
matlab image-processing
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 pixelwheresWaldo(i, j, :)
that matches the top-left pixel ofWaldo
. (btw, you could implement that longif
statement withisequal
.) Before the edit you had another double loop to iterate over all elements ofWaldo
and match them to the current location inwheresWaldo
. You need that loop.
– beaker
Nov 11 at 17:41
add a comment |
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 pixelwheresWaldo(i, j, :)
that matches the top-left pixel ofWaldo
. (btw, you could implement that longif
statement withisequal
.) Before the edit you had another double loop to iterate over all elements ofWaldo
and match them to the current location inwheresWaldo
. 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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 ofWaldo
. (btw, you could implement that longif
statement withisequal
.) Before the edit you had another double loop to iterate over all elements ofWaldo
and match them to the current location inwheresWaldo
. You need that loop.– beaker
Nov 11 at 17:41