Click to See Complete Forum and Search --> : Find coordinates of image
king4lex
August 24th, 2005, 12:24 PM
Hello,
I have two images, (A) and (B). (B) is much larger than (A) and I know it includes (A) somewhere in it. I want to find the coordinates of (A) in (B). How can I do this?
--king4lex
aewarnick
August 24th, 2005, 01:06 PM
If you have the pixel data of A and B then you can just loop through B finding the corrosponding pixels of A in B.
It is not hard to do as long as you know how to get pixel data and loop through it.
king4lex
August 25th, 2005, 06:42 PM
It is not hard to do as long as you know how to get pixel data and loop through it.
*embarassed grin* That's actually what I was wondering in my first post. I dont know how to go about doing that.
andytim
August 29th, 2005, 02:26 AM
I think you need compare thest two image's pixel data (RGBA value),to finish this work,it will be very easy,just loop the two images width and height.
Jack
---------------------------------------------------------------------------------
XD++ MFC/C++ Flow/Diagram Library (Source Code Kit) -- http://www.********.net
aewarnick
August 29th, 2005, 09:04 AM
Check into GetObject with BITMAP
bmBits - pointer to first byte in image.
bmBitsPixel - Bits per pixel
bmWidthBytes - the byte width of one row in image (very important)
yiannakop
September 10th, 2005, 07:15 AM
You said B includes A. Does this mean that "exctactly" A is included is B? (I don't know how to express this in good English). If the answer is yes (A is 100% included in B), then the problem is quite simple:
B: [K,L]
A: [M,N]
for i=1:K
{
for j=1:L
{
isEqual = TRUE;
while (m<M)&&(isEqual==TRUE)
{
n = 1;
while (n<N)&&(isEqual==TRUE)
{
if (B[i,j]!=A[m,n])
isEqual = FALSE; // equality condition is changed
n++;
}
m++;
}
}
}
I have not tested the pseudo-code but it must be sth like that.
Now, if A is not exctactly included in B, but an image "like" A does, then the problem becomes harder: you have to use pattern recognition techniques, or sth like that. For example, if a scaled or rotated version of A is included in B (instead of A itself), you could use central moments (try to find this in the net) which are generaly independed of rotation and scaling. Again you will have to loop over the big image, but instead of pixel values you will have to compare the central moments (or any other feature you will use).
Regards,
Theodore
yiannakop
September 10th, 2005, 07:18 AM
About the pseudo-code, I forgot to say that at the end of the 2 internal loops, if isEqual is still TRUE, then the image has been found, and you should "break" out of the outer loops.
Also, the above code would be very easily implemented in Matlab (without using so many loops), since you can use matrix operations for image comparing. If Matlab is ok for you, let me know to post an example code.
Regards,
Theodore
golanshahar
September 10th, 2005, 09:13 AM
read this thread might help you out ;)
find bmp in bmp (http://www.codeguru.com/forum/showthread.php?t=354984)
Cheers
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.