6 Replies Latest reply on Jul 15, 2010 7:11 AM by thebestcpu

    Delta encoding

    Ghoulfool Level 1

      Not sure if this is possible at all but could a script be written to determine the delta changes between a series of images (ie a number of animation frames) and for the script to work out what changes are made compared to either the previous frame or first frame. Basically it's an image analysis and I'm not sure if photoshop is up to that (difference layers being the only thing that springs to mind to help)

      Cheers

        • 1. Re: Delta encoding
          thebestcpu Level 1

          I could benefit from a little more details on your needs to think about alternatives for what your are tyring to do.

          - Are you interested in just 8 bit RGB images (my assumption yet thought I would ask)?

          - Do you need to have the delta changes be exact i.e. so you could exactly recreate the frames from the original frame and all the deltas?  Or if the delta were within 1 bit would that be close enough?

           

          So an understanding of what you are tying to achieve with your project would help.

           

          Assuming that you want an exact examination of the delta encoding frame to frame the Difference Blend mode does not quite do it.  The Difference Blend mode only gives you the magnitude of the change not whether it was a postive or negative change from your reference frame.  I assume that from one frame to the next you could have a full 256 bit swing (e.g.  full black to full white or visa versa).   If you need to know more than the magnitude of the swing and also need the "sign" (positive/negative) of the delta and also need it exact to single bit accuracy, then you need to record a full +/- 256 bits or 512 bits of information per pixel per frame.  That does not fit in 8 bit mode to start out.  I can envision ways to encode this using 16 bit mode and alternate blend modes to do the job or by given up on the exact accuracy of the delta (e.g.  single bit of accuracy) and encoding the full swing info into 8 bit mode.   If you only need a sense of how much has changed from the previous frame (or beginning frame) then going with difference blend and 8 bit mode would also be feasible.

           

          Before getting into scripting options it seems that understanding what you want to achieve with a little more clarity might guide the suggestions you get back.

           

          Hope the questions I posed back make sense

           

          John Wheeler

          • 2. Re: Delta encoding
            Ghoulfool Level 1

            John, thanks for your interest:

            Okay, I'll try to explain what my idea is:

            At the moment I'm saving out my animation frames as a series of 32 bit PNGs (with transparant background) roughly in the ball park of 150 x 150 pixels of about 10 frames each. They're roughly 100 KB for those 10 frames. (I may confuse matters to explain that the images are of few colours - less than 256 colours but are not palettized). I was hoping to use delta changes to reduce the filesize of the overall animation frames. I have in the past (when using 8 bit images) mananged to work out the delta changes with a gif animation program by saving out two versions of the animation. The original uncompressed version and the second compressed version. I was then able to go through the latter and extract the changes by hand on a frame by frame basis. This processs is quite tedious and I was hoping to speed up this process.

            frame_1_and_delta.png

            blink_anim.gif

             

            I've included a very simple example. The first image is the first frame of the blink animation and the second is the delta change (which in this case is just the eyes which is in a format of the smallest available rectangle for each change which could be superimposed over the first frame). See the animation below for what it would look like. As for a 1bit delta change I couldn't say if that would be enough.

            The question I need to be asking is not can a script do this, but how would be the best way to get from the two full frames of animation to generate the new delta change frame (the right hand frame in the topmost example). How would I go about that. It might be a case of further research into video codecs.

            • 3. Re: Delta encoding
              thebestcpu Level 1

              I believe I do have a solution for you and will explain in three images below.

               

              I will cover grayscale images and there is one modification to cover color images

               

              As per picture below.

              First Layer is original picture Normal Blend

              Sedond Layer is second frame set to Difference Blend

              Third Layer is set to pure white and Color Dodge Blend

              Fourth Layer is second frame set to Normal Blend yet is turned off at this point in the process.

               

              The above steps will create a pure white and pure black image of just the differences between the two frames.

               

              http://i774.photobucket.com/albums/yy26/thebestcpu/NAPP%20General/Screenshot2010-07-13at44958PM-2.png

               

              Next, create a selection  using Select > Color Range      and use "HIghlights" from the drop down box and have the Invert checkbox selected.  Once this is done turn on the top Layer and Turn Off all the other Layers.  You should see a picture as follows:

               

              http://i774.photobucket.com/albums/yy26/thebestcpu/NAPP%20General/Screenshot2010-07-13at45044PM-2.png

               

              Now just use Edit > Clear and then deselect the selection and you should see just the Delta Image over a transparent field as below:

               

              http://i774.photobucket.com/albums/yy26/thebestcpu/NAPP%20General/Screenshot2010-07-13at45149PM-2.png

               

              If this image is overlayed over your original picture, you will get exactly your second frame.

               

              This tells you how to do this and I believe this can be done with an action and not even need a script.   Hope this gives you a starting point and maybe others could help if you need the specific script now that the above shows how to create the delta image at least from separate Layers.

               

              John Wheeler

              • 4. Re: Delta encoding
                thebestcpu Level 1

                Forgot to mention what to change when you have color RGB frames that you want to do a delta analysis on.

                 

                All you have to do is insert one layer right above the lowest Second Frame layer and insert a Channel Mixer layer with all channels set at source being all three R,G,B set at 100%.  No other changes are needed and this works for color delta frames as well.

                John Wheeler

                 

                 

                http://i774.photobucket.com/albums/yy26/thebestcpu/NAPP%20General/Screenshot2010-07-13at51213PM-2.png

                • 5. Re: Delta encoding
                  Ghoulfool Level 1

                  Thank you very much John, that makes a lot of sense. I hope to be able to use that method for an action or script. Cheers!

                  • 6. Re: Delta encoding
                    thebestcpu Level 1

                    Your welcome and good luck

                    John Wheeler