Click here to Skip to main content
15,918,243 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi, I have been searching for a method that can locate the X and Y position of a smaller image inside a larger image (cropped screenshot) (only if the smaller image exists, sometimes it doesnt), i have found some solutions but i couldnt get any of them to work the way i needed

this is the my larger image
http://imageshack.us/photo/my-images/21/canchk.png/
and this is my smaller image
http://imageshack.us/photo/my-images/842/mycan.png/

Basically i need a method that i can call like this
findImagePos(SmallImage,LargeImage,X_array_varible, Y_array_varible, number_of_images_found_varible)

if no image is found then the number_of_images_found_varible would be 0
else number_of_images_found_varible would equal how many images where found
and X_array_varible[0] would have the X position of the first found image
and Y_array_varible[0] would have the Y position of the first found image
etc....

Thanks for any help
Posted
Updated 29-Jun-11 5:19am
v3

I think that AForge can help you, look here Template matching
 
Share this answer
 
Comments
Yuri Vital 29-Jun-11 11:48am    
[....]
foreach ( TemplateMatch m in matchings )
{
// you have the m.Rectangle property that indicate the position of the image

// do something else with matching
}
sourceImage.UnlockBits( data );
Member 8034122 29-Jun-11 11:59am    
just been reading up on it and this seems like exactly what I need
awesome thanks alot
Yuri Vital 29-Jun-11 12:05pm    
you are welcome !
You mean thumbnail image ?
In this case here a link that can help you :
create thumbnail
 
Share this answer
 
Comments
Member 8034122 29-Jun-11 10:53am    
no I need to FIND the smaller image in the larger image, not create a thumbnail, if you look at my attached images you can see what I mean, I need to find the mycan.png in the canchk.png
Yuri Vital 29-Jun-11 10:54am    
Did you even read the link ?
It use the function : photoImg.GetThumbnailImage(50, 40, null, new System.IntPtr())) who retrieve the thumbnail !
Member 8034122 29-Jun-11 10:57am    
yes I did, from what I can tell that is just cropping a smaller image from a larger image
Yuri Vital 29-Jun-11 11:01am    
And what you need realy ?
Pattern recognition ?
Border detection ?

If you want image manipulation, you can use the library AForge
http://code.google.com/p/aforge/
Member 8034122 29-Jun-11 11:01am    
i want to FIND the smaller image in the larger image i need the X and Y relative to the uppper left (0,0) of the larger image, not create a smaller image from the larger image, i updated my question, i hope i explained it more clearly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900