Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

[MBS] Best way to compare 2 pictures documents (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] Duplicate posts... always?
Next thread: [MBS] 8.0pr1


[MBS] Best way to compare 2 pictures documents   -   Louis
  Re: [MBS] Best way to compare 2 pictures documents   -   Christian Schmitz
  Re: [MBS] Best way to compare 2 pictures documents   -   Tim Jones
   Re: [MBS] Best way to compare 2 pictures documents   -   Christian Schmitz
    Re: [MBS] Best way to compare 2 pictures documents   -   Tim Jones
     Re: [MBS] Best way to compare 2 pictures documents   -   Christian Schmitz
  Re: [MBS] Best way to compare 2 pictures documents   -   Louis
   Re: [MBS] Best way to compare 2 pictures documents   -   Christian Schmitz

[MBS] Best way to compare 2 pictures documents
Date: 01.01.08 20:11 (Tue, 01 Jan 2008 14:11:10 -0500)
From: Louis
Hello Christian,

I'm trying to build a simple system to compare two pictures.

And when I say pictures I mean duplicate picture documents.

The way I found is to open a first picture reference document...

Then I do a DrawPictureMBS with a subPin option.

Finaly, I check the resulting picture with the minmax class to see if all
max are at 0, if they are, both pictures are the same...

But as I expected, this whole process is rather slow. Still it beats doing
it by hand, but I'm sure there's a better way in the MBS plugin spice rack
:) any suggestion?

Once more, thanx Christian and happy new year to the list!

Louis

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
http://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Best way to compare 2 pictures documents
Date: 01.01.08 21:40 (Tue, 1 Jan 2008 21:40:41 +0100)
From: Christian Schmitz
Louis <<email address removed>> wrote:

> Hello Christian,
>
> I'm trying to build a simple system to compare two pictures.
> And when I say pictures I mean duplicate picture documents.

Well, there are several levels of comparison on this.

e.g.
- compare each pixel
- compare file bytes
- compare each pixels divided by channels

and how to know whether two pictures look equal?

e.g. a png file and a jpg file where the jpg has a little bit loose.

I can of course write a picture.comparembs function if you tell me how
it should work.

Gruß
Christian

-

Re: [MBS] Best way to compare 2 pictures documents
Date: 02.01.08 14:55 (Wed, 2 Jan 2008 06:55:55 -0700)
From: Tim Jones
On Jan 1, 2008, at 12:11 PM, Louis wrote:

> But as I expected, this whole process is rather slow. Still it
> beats doing
> it by hand, but I'm sure there's a better way in the MBS plugin
> spice rack
> :) any suggestion?

Louis,

This would depend on the creator of the images. You can actually
generate a JPG twice from the same original PSD and not get the exact
same image each time. In fact, there's no guarantee that any lossy
format will always generate the same image each time you process the
original. However, with that said, if you're sure the data will be
exact on equal documents, I;d recommend comparing the two images via
a shell call to 'diff'. I can't think of any straightforward way
outside of what you've currently described programatically to do this.

HTH,
Tim

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
http://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Best way to compare 2 pictures documents
Date: 02.01.08 15:01 (Wed, 2 Jan 2008 15:01:06 +0100)
From: Christian Schmitz
Tim Jones <<email address removed>> wrote:

> I;d recommend comparing the two images via a shell call to 'diff'.

For a binary comparison, a binarystream and strcomp would be enough.

Gruß
Christian

-

Re: [MBS] Best way to compare 2 pictures documents
Date: 02.01.08 17:00 (Wed, 2 Jan 2008 09:00:59 -0700)
From: Tim Jones
On Jan 2, 2008, at 7:01 AM, Christian Schmitz wrote:

> Tim Jones <<email address removed>> wrote:
>
>> I'd recommend comparing the two images via a shell call to 'diff'.
>
> For a binary comparison, a binarystream and strcomp would be enough.

I just tried this and yes it is possible, but shelling out to 'diff'
was over 2 seconds faster on a 10MB PDF (as an example). Also, on
really big files, diff uses a much smaller memory model than reading
the files into variables and then strcomp'ing them.

Tim

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
http://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Best way to compare 2 pictures documents
Date: 02.01.08 18:54 (Wed, 2 Jan 2008 18:54:44 +0100)
From: Christian Schmitz
Tim Jones <<email address removed>> wrote:

> Also, on really big files, diff uses a much smaller memory model than
> reading the files into variables and then strcomp'ing them.

If you read it in small blocks (e.g. one MB), you can stop as soon as
you found a difference.

Gruß
Christian

-

Re: [MBS] Best way to compare 2 pictures documents
Date: 02.01.08 19:41 (Wed, 02 Jan 2008 13:41:49 -0500)
From: Louis
> - compare each pixel
> - compare file bytes
> - compare each pixels divided by channels
>
> and how to know whether two pictures look equal?
> e.g. a png file and a jpg file where the jpg has a little bit loose.
True, maybe it should be a function in itself, with a few properties on how
loose this mtach can be ex:
- full equal file and picture, where you use the file bytes
- equal image file, but not taking into account metadata, like tags and
descriptions and such
- somewhat similar pictures, not taking into account anything else and
letting the user specify a percentage for closeness, that way, you subtract
pixels from image A and B, then if this difference is 0 everywhere, we have
true and exact match, otherwise you average all the difference and see if
this average fit within a user specified range.


> I can of course write a picture.comparembs function if you tell me how
> it should work.
Does the above spec seems reasonable? maybe other users could comment on the
properties that they would like and that I may have forgot.

And of course, I forgot one important spec: speed. I know it's always a
requirement, but especialy with this function there's a lot of slow stuff
going on, like having to open files and render their content offscreen...

It might also be nice to be able to read as a property the rendered picture
of the difference between A and B for those who need to see the process in
action...

Louis

>
> Gruß
> Christian

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
http://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Best way to compare 2 pictures documents
Date: 02.01.08 20:21 (Wed, 2 Jan 2008 20:21:00 +0100)
From: Christian Schmitz
Louis <<email address removed>> wrote:

> True, maybe it should be a function in itself, with a few properties on how
> loose this mtach can be ex...

Far to complicate for a few plugin functions.

A function to check two files being equal can be written in RB fast.
And for the image content, you need to have functions to load picture or
at least knowledge of the image file format.

I can write a picture.EqualPixelsMBS(pic as picture) as boolean function
to tell you whether two picture objects have the same pixels inside.

> And of course, I forgot one important spec: speed.

The question on speed is what you really need.

For example if you check the file size first, you could say, that two
files have different size, they have different content.

But if the metadata is just the difference, that would be bad.

If you want to compare pixels, you may prefer some checksum function so
you can store a checksum of each file to compare the checksums in case
you compare each with each.

If the checksum is different, the images are different.
If the checksum is equal, you have to compare pixels.

Gruß
Christian

-