Re: Compare images in Cocoa
Re: Compare images in Cocoa
- Subject: Re: Compare images in Cocoa
- From: Graham Cox <email@hidden>
- Date: Fri, 31 Oct 2008 16:30:29 +1100
On 31 Oct 2008, at 4:04 pm, Graham Cox wrote:
On 31 Oct 2008, at 2:21 pm, Pierce Freeman wrote:
Hi everyone. I am wondering if there is some way to compare two
images in
Cocoa, and then somehow spit out a percent of how similar they are.
The only
way I could think of is comparing every pixel, but this seems like
it would
take a long time, and even so I have no idea how to go about doing
that.
A further thought that might be more fruitful, though it's completely
off the top of my head.
When a movie is encoded as MPEG or something similar, there are
different types of frames. There are frames that are basically a
complete image, which occur at intervals, and in-between frames, which
are encoded as the difference from the previous frame. The difference
encoding breaks down an image into blocks of say, 8 x 8 pixels, then
encodes each one using a discrete cosine transform (DCT). The
coefficients of this transform are just a list of numbers, which can
be compared to the coefficients for a key frame. If a match is found,
the position of this match is recorded and transmitted in the stream.
For decoding, the decoder simply re-uses the block from the key frame
at the indexed position instead of decoding the block anew. This
significantly saves time and bandwidth. Additional substantial
compression is achieved by throwing away a certain amount of the
lesser contributing coefficients, making a match on the remainder more
likely at the expense of image quality.
So much for that. The point is that you might be able to use the same
approach to determine the similarity of two images. Encode one as a
keyframe - basically just a JPEG - then encode the second using the
MPEG differential encoding approach. The size of the encoded data in
proportion to a straight JPEG encoding would give you a rough measure
of the similarity of the two images - the smaller the differences the
smaller would the encoded data be. You might be able to use available
MPEG code to perform this work.
I'd be interested to know if anyone thinks this is feasible!
cheers, Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden