This is some old nasty FORTRAN, but should give you the basic approach. It is not that difficult at all. Due to the fact that I am doing it on a two colour pallette you would do this operation for R, G and B. That is compute the intensities or values in each cell/pixal, store them in some array. Do the same for the other image, and subtract one array from the other, this will leave you with some coulorfull subtraction image. My advice would be to do as the lads suggest above, compute the magnitude of the sum of the R, G and B componants so you just get one value. Write that to array, do the same for the other image, then subtract. Then create a new range for either R, G or B and map the resulting subtracted array to this, the will enable a much clearer picture as a result.
* =============================================================
      SUBROUTINE SUBTRACT(FNAME1,FNAME2,IOS)
*     This routine writes a model to files
* =============================================================
*    Common :
      INCLUDE 'CONST.CMN'
      INCLUDE 'IO.CMN'
      INCLUDE 'SYNCH.CMN'
      INCLUDE 'PGP.CMN'
*    Input :
      CHARACTER fname1*(sznam),fname2*(sznam)
*    Output :
      integer IOS
*    Variables:
       logical glue
       character fullname*(szlin)
       character dir*(szlin),ftype*(3)
       integer i,j,nxy1,nxy2
       real si1(2*maxc,2*maxc),si2(2*maxc,2*maxc)
* =================================================================
       IOS = 1
       nomap=.true.
       ftype='map'
       dir='./pictures'
!    reading first image
       if(.not.glue(dir,fname2,ftype,fullname))then
           write(*,31) fullname
           return
       endif
       OPEN(unit2,status='old',name=fullname,form='unformatted',err=10,iostat=ios)
       read(unit2,err=11)nxy2
       read(unit2,err=11)rad,dxy
       do i=1,nxy2
          do j=1,nxy2
             read(unit2,err=11)si2(i,j)
          enddo
       enddo
       CLOSE(unit2)
!    reading second image
       if(.not.glue(dir,fname1,ftype,fullname))then
           write(*,31) fullname
           return
       endif
       OPEN(unit2,status='old',name=fullname,form='unformatted',err=10,iostat=ios)
       read(unit2,err=11)nxy1
       read(unit2,err=11)rad,dxy
       do i=1,nxy1
          do j=1,nxy1
             read(unit2,err=11)si1(i,j)
          enddo
       enddo
       CLOSE(unit2)
!    substracting images 
       if(nxy1.eq.nxy2)then 
           nxy=nxy1
           do i=1,nxy1
              do j=1,nxy1
                 si(i,j)=si2(i,j)-si1(i,j)
              enddo
           enddo
       else
          print *,'SUBSTRACT: Different sizes of image arrays'
          IOS=0 
          return
       endif
*  normal finishing
       IOS=0 
       nomap=.false.
       return
*  exceptional finishing
10     write (*,30) fullname
       return
11     write (*,32) fullname
       return
30     format('Cannot open file   ',72A)
31     format('Improper filename   ',72A)
32     format('Error reading from file   ',72A)
      end
! =============================================================
Hope this is of some use. All the best.