Dude, Komtanoo Pinpimai wrote:
> I want to place the second rectangular into the first one with the least > overlaped pixels. > (the second regtangular can be placed exceedingly the > bound of the larger reg., but it is worse than overlaped pixel) ( FYI: it's "exceeding", not "exceedingly". ) The imaging problems I work with are in the area of printer enhancement, so I haven't had to solve your exact problem, but here's a shot. first of all, if the pixels are totally random, then brute force is the only way I can think of. If the pixels are formed from some larger pattern, you might be able to take advantage of the pattern. most simplistic, if the image is a silhouette of a solid object with no convex angles, then you could calculate the "center of mass" of object 1 and the "center of white" of image 1, draw a line from the center of mass to the center of white, and extend it until you hit the edge of image 1. Then find the center of mass of object 2, and place it somewhere along the line you drew. I'd probably start at the center of white, then move closer and further away by one pixel, see which one improves, then keep going that direction until it gets worse again. if you have two objects relatively small compared to the size of the images, this will work. They don't even have to be convex, they just have to be fairly "blob-like". since you didn't say anything about the image patterns, this might not be useful for your application. if you have two tiger-stripe patterns, then both will have a center-of-mass and center-of-white near the center of their images. if the stripes are roughly parallel, then you'd want to move the smaller image perpendicular to the direction of the stripes. And the above approach is useless. still, you say that the second image is always smaller than the first, so it might give you a good first guess. Greg _______________________________________________ Boston-pm mailing list [EMAIL PROTECTED] http://mail.pm.org/mailman/listinfo/boston-pm

