Difference between two images.

Difference between two images.

Post by Dr. David Kirkb » Tue, 27 May 2003 21:18:47


Hi,
        First I'm a scientist, not too interested in graphics and know little
of Gimp. I have written a scientific program that writes bitmap files.
The program has been run on two systems, but produces *slightly*
different results on each. This could be due to rounding errors in
their respective CPUs, but I want to check this.

Anyway, I want to find the difference between two bitmaps, to see
where they differ (what pixel). The two images are at

http://www.medphys.ucl.ac.uk/~davek/tiger.bmp
http://www.medphys.ucl.ac.uk/~davek/sparrow.bmp

Can anyone tell me how to find the difference between these two images
in gimp. By that I mean take the subtract one image from another and
see where the results is non zero.

I could write a program to do this, but if anyone can suggest how to
go about doing it in the Gimp, bearing in mind I have *very* little
knowledge of this program, please let me know.
--
Dr. David Kirkby,
Senior Research Fellow,
Department of Medical Physics,
University College London,
11-20 Capper St, London, WC1E 6JA.
Tel: 020 7679 6408 Fax: 020 7679 6269
Internal telephone: ext 46408


 
 
 

Difference between two images.

Post by i.. » Tue, 27 May 2003 23:50:19



> Hi,
> First I'm a scientist, not too interested in graphics and know little
> of Gimp. I have written a scientific program that writes bitmap files.
> The program has been run on two systems, but produces *slightly*
> different results on each. This could be due to rounding errors in
> their respective CPUs, but I want to check this.

> Anyway, I want to find the difference between two bitmaps, to see
> where they differ (what pixel). The two images are at

> http://www.medphys.ucl.ac.uk/~davek/tiger.bmp
> http://www.medphys.ucl.ac.uk/~davek/sparrow.bmp

> Can anyone tell me how to find the difference between these two images
> in gimp. By that I mean take the subtract one image from another and
> see where the results is non zero.

> I could write a program to do this, but if anyone can suggest how to
> go about doing it in the Gimp, bearing in mind I have *very* little
> knowledge of this program, please let me know.

The program is trivial, and will allow you to evaluate the
actual numerical differences, as well as create a new bmp
for viewing:

-- Euphoria code;

object f1, f2, f3
integer count, c1, c2

count = 0
f1 = open("sparrow.bmp","rb")
f2 = open("tiger.bmp","rb")
f3 = open("diffs.bmp","wb")

while 1 do
 c1 = getc(f1)
 c2 = getc(f2)
 count += 1
 if c1 = -1 or c2 = -1 then exit -- eof
 else
  if count < 55 then puts(f3,c1)
  elsif c1 = c2 then puts(f3,0)
  else puts(f3,#FF)
       printf(1,"AT: %d, C1:%d C2:%d\n",{count,c1,c2})
  end if
end if
end while

close(f1)
close(f2)
close(f3)

-- note: in your samples, three bytes differ:
--AT: 56201, C1:254 C2:255
--AT: 56202, C1:254 C2:255
--AT: 56203, C1:254 C2:255

Irv

 
 
 

Difference between two images.

Post by dauph » Wed, 28 May 2003 21:53:24


great pix !
is there a copyright on it ?
i would love use it as a pix for my widgets <rire /

big kiss


>Hi,
>    First I'm a scientist, not too interested in graphics and know little
>of Gimp. I have written a scientific program that writes bitmap files.
>The program has been run on two systems, but produces *slightly*
>different results on each. This could be due to rounding errors in
>their respective CPUs, but I want to check this.

>Anyway, I want to find the difference between two bitmaps, to see
>where they differ (what pixel). The two images are at

>http://www.medphys.ucl.ac.uk/~davek/tiger.bmp
>http://www.medphys.ucl.ac.uk/~davek/sparrow.bmp

>Can anyone tell me how to find the difference between these two images
>in gimp. By that I mean take the subtract one image from another and
>see where the results is non zero.

>I could write a program to do this, but if anyone can suggest how to
>go about doing it in the Gimp, bearing in mind I have *very* little
>knowledge of this program, please let me know.

 
 
 

Difference between two images.

Post by Leonard Even » Wed, 28 May 2003 23:39:35




>>Hi,
>>First I'm a scientist, not too interested in graphics and know little
>>of Gimp. I have written a scientific program that writes bitmap files.
>>The program has been run on two systems, but produces *slightly*
>>different results on each. This could be due to rounding errors in
>>their respective CPUs, but I want to check this.

>>Anyway, I want to find the difference between two bitmaps, to see
>>where they differ (what pixel). The two images are at

>>http://www.medphys.ucl.ac.uk/~davek/tiger.bmp
>>http://www.medphys.ucl.ac.uk/~davek/sparrow.bmp

>>Can anyone tell me how to find the difference between these two images
>>in gimp. By that I mean take the subtract one image from another and
>>see where the results is non zero.

>>I could write a program to do this, but if anyone can suggest how to
>>go about doing it in the Gimp, bearing in mind I have *very* little
>>knowledge of this program, please let me know.

> The program is trivial, and will allow you to evaluate the
> actual numerical differences, as well as create a new bmp
> for viewing:

> -- Euphoria code;

> object f1, f2, f3
> integer count, c1, c2

> count = 0
> f1 = open("sparrow.bmp","rb")
> f2 = open("tiger.bmp","rb")
> f3 = open("diffs.bmp","wb")

> while 1 do
>  c1 = getc(f1)
>  c2 = getc(f2)
>  count += 1
>  if c1 = -1 or c2 = -1 then exit -- eof
>  else
>   if count < 55 then puts(f3,c1)
>   elsif c1 = c2 then puts(f3,0)
>   else puts(f3,#FF)
>        printf(1,"AT: %d, C1:%d C2:%d\n",{count,c1,c2})
>   end if
> end if
> end while

> close(f1)
> close(f2)
> close(f3)

> -- note: in your samples, three bytes differ:
> --AT: 56201, C1:254 C2:255
> --AT: 56202, C1:254 C2:255
> --AT: 56203, C1:254 C2:255

> Irv

This is certainly the best way to do it.

To do it in the Gimp, I opened both images, made a new layer for one of
them to which the other was copied. I then changed the blending mode to
difference, and then flattened the image.  I then used levels to show
only values between 0 and 1, and one pixel popped up, the one at 322,
31. This is the pixel at the extreme left of the right hand pattern.
Checking values, I found in confirmation that it was 255, in all three
channels, for one of the images and 254 for the other.

This is consistent with the what the program showed since the images as
the Gimp read them in were RGB images, so there were three bytes for
each pixel.

--

Dept. of Mathematics, Northwestern Univ., Evanston, IL 60208

 
 
 

Difference between two images.

Post by Leonard Even » Wed, 28 May 2003 23:51:20



> Hi,
>    First I'm a scientist, not too interested in graphics and know little
> of Gimp. I have written a scientific program that writes bitmap files.
> The program has been run on two systems, but produces *slightly*
> different results on each. This could be due to rounding errors in
> their respective CPUs, but I want to check this.

I don't know what kind of systems or what the program did, but it seems
to me that to produce a difference of 1 out of 256 values (in a byte)
would require an rather unusual set of circumstances.  After all
floating point numbers carry a very large number of significant digits,
and one would have to hit the boundary line just right for the
difference between rounding up and rounding down to make such a
difference.  Also, it is more likely that any difference is attributable
to a difference in compilers than in a difference in cpus.

There may be something else going on, and you should consult an expert.
  I'm sure you can find a mathematician or computer scientist at
University College who is knowledgeable enough about such matters to
help you.

Quote:> Anyway, I want to find the difference between two bitmaps, to see
> where they differ (what pixel). The two images are at

> http://www.medphys.ucl.ac.uk/~davek/tiger.bmp
> http://www.medphys.ucl.ac.uk/~davek/sparrow.bmp

> Can anyone tell me how to find the difference between these two images
> in gimp. By that I mean take the subtract one image from another and
> see where the results is non zero.

> I could write a program to do this, but if anyone can suggest how to
> go about doing it in the Gimp, bearing in mind I have *very* little
> knowledge of this program, please let me know.

--

Dept. of Mathematics, Northwestern Univ., Evanston, IL 60208
 
 
 

1. Difference comparison of two images

Now I know this has to be possible:

The idea I have is to have two separate images.  The first image is
just the background...that is, a still shot of a room.  The second
picture has the same room in the background, but now includes a
foreground object (well...an animal).  The camera doesn't move for
either shot.

I'm wondering how one goes about comparing the two images, masking out
the parts of the images that are the same (i.e., the background room),
thereby leaving just the animal in the second image.  

Is there a name for this method, and secondly, is there a plugin,
program, or process to do this in PS?

I've been trying to figure this out for some time, so any help would
be greatly appreciated.

Thankx,

- Jason S

2. Loking for a Football (soccer) Model or tutorial

3. Two Images: make differences Alpha/invisible

4. scanner software?

5. Help with Two Cylinders & CSG Difference

6. Taking the difference of two selections

7. Difference between two newsgroups

8. Determining amount of difference in two pictures

9. (Percieved) Difference between two colours ?

10. how to calculate difference between two rotation in 3d space