12 Replies Latest reply on Apr 7, 2010 2:56 AM by George Austin

    translate histogram

    alexxxmg

      hi group,

      I hope I'll be able to make you understand what I'd like to do, since I'm not expert in graphic processing.

       

      I have a set of graylevel images (successive microscope acquisitions), and some of those are - on the average - brighter, or darker.

      I'd like to choose a reference point on all the images, and change their brightness so that all the images are the same gray value <at that point>.

      I want to make sure that I do not stretch or deform their histogram, since it contains important informations, so I guess it should be

      some kind of histogram translation.

      Finally, since the images are many, it is an operation that I should be able to convert into an Action, so it cannot involve any

      manual slider settings...

      do you think it is possible???

       

      thanks!

       

       

      alessandro

        • 1. Re: translate histogram
          Mylenium Most Valuable Participant

          http://www.adobe.com/products/aftereffects/

           

          http://www.gbtimelapse.com/Products/ProductGBD.aspx

           

          I'm sure you can also do this with Photomerge, ACR or some other tools I nwever use in Photoshop, so maybe someone else has some ideas.

           

          Mylenium

          • 2. Re: translate histogram
            Paulo Skylar Level 4

            I will not address the automation aspect of your query except to say that easy automation would require that your reference point have the same pixel location (X,Y) in every image:  it should then be possible.

             

            One way you can translate your histogram is add a layer to your subject image and fill it with a gray level  (Edit > Fill ... ).  Then click on  Image > Calculations ..  Source 1 can be your subject , source 2 your layer filled with gray.  For the blending mode choose Add and set the result as a new channel.   The resulting new channel will  be your subject image shifted by the gray level you choose and thus has a translated histogram.   You can use either a different gray level for each image in your sequence to get the desired translation or used a fixed level and change the offset in the calculations dialog box.

             

            If this were a one shot analysis and I had less than say 100 images, I might just do the translations manually.  Otherwise I would persue developing an action or script to get the work done.

             

            Paulo

            • 3. Re: translate histogram
              Semaphoric Adobe Community Professional

              Making a Brightness adjustment will translate the histogram. Some clipping in the shadows or highlights may occur, though.

              • 4. Re: translate histogram
                alexxxmg Level 1

                thank you everybody,

                I guess I'm almost there, but not quite.

                The following by Paulo was the nearest solution:

                One way you can translate your histogram is add a layer to your subject image and fill it with a gray level  (Edit > Fill ... ).  Then click on  Image > Calculations ..  Source 1 can be your subject , source 2 your layer filled with gray.  For the blending mode choose Add and set the result as a new channel.   The resulting new channel will  be your subject image shifted by the gray level you choose and thus has a translated histogram.   You can use either a different gray level for each image in your sequence to get the desired translation or used a fixed level and change the offset in the calculations dialog box.

                 

                but it has a drawback: it allows me to shift the histogram by a given amount (the graylevel of the new filled layer) - an operation that I can repeat for all the images.

                But I already could accomplish this by a constant brightness increase!

                 

                I should find a way instead to shift the histogram differently for the different images, so that, at the end, the graylevel at a given position (constant for all the images, say the top-left pixel of every image) is the same...

                 

                 

                alessandro

                • 5. Re: translate histogram
                  Semaphoric Adobe Community Professional

                  Well, you could make an action that places a new Color Sampler point at 0,0 (upper left), and adds a Brightness/Contrast Adjustment Layer. Make sure you have the Info palette/panel open, and run this Action on your reference image. Make a note of the value of the sampled color; you may want to set the Color Readouts to grayscale (via the palette menu), so you only have one number to deal with.

                   

                  Now, open an image you wish to adjust. Run the action on it. Adjust the Brightness slider until the second color readout of the Sample in the Info Panel is the same as that in your reference image.

                  • 6. Re: translate histogram
                    George Austin Level 2

                    " I should find a way instead to shift the histogram differently for the different images, so that, at the end, the graylevel at a given position (constant for all the images, say the top-left pixel of every image) is the same"

                     

                    For a grayscale image, the following code placed in the r,g, and b boxes in Filter Factory will do exactly that:

                     

                    put(src(x,y,0),0),get(0) -V +r

                     

                    where x,y are the x and y coordinates (in pixels) of the reference position in the images and V is the grayscale value (0-255) to be common at that position

                     

                    You then need an action to apply this filter to all images

                    • 7. Re: translate histogram
                      alexxxmg Level 1

                      For a grayscale image, the following code placed in the r,g, and b boxes in Filter Factory will do exactly that:



                      put(src(x,y,0),0),get(0) -V +r



                      where x,y are the x and y coordinates (in pixels) of the reference position in the images and V is the grayscale value (0-255) to be common at that position



                      You then need an action to apply this filter to all images

                       

                      For a moment I thought my problem was solved...

                      Damn, I soon discovered that FilterFactory is an old product, unavailable/unsupported (I have CS3 on OSX) - or is it? Do you know where I could find it?

                      I tried an alternative: FilterFoundry, but it returns errors whenever I try to use it.

                      What people use now that FilterFactory is not available? I liked that syntax, it seems it was a quite powerful/programmable filter engine!

                       

                      alessandro

                      • 8. Re: translate histogram
                        Christian Davideck Level 1

                        alexxxmg wrote:

                         

                        Damn, I soon discovered that FilterFactory is an old product, unavailable/unsupported (I have CS3 on OSX) - or is it? Do you know where I could find it?

                         

                        I have CS3 and FilterFactory is definitely running here. I don't remember if it was on the CS3 installation disc or an earlier version but all you have to do is copy the files from your disc to your plugins folder (I think it's just Ffactory.8bf).

                        • 9. Re: translate histogram
                          Semaphoric Adobe Community Professional

                          I skipped CS3, but on CS2, it was in the Resources ans Extras disc, at Goodies\Photoshop CS2\Optional Plug-ins\Ffactory.

                          • 10. Re: translate histogram
                            Paulo Skylar Level 4

                            alexxxmg wrote:

                             

                            ........

                             

                            but it has a drawback: it allows me to shift the histogram by a given amount (the graylevel of the new filled layer) - an operation that I can repeat for all the images.

                            But I already could accomplish this by a constant brightness increase!

                             

                            .........

                             

                             

                            alessandro

                             

                            My recollection of a brightness adjustment in CS3 was that it did not preserve the histogram in detail. I seem to recall checking this in the Extended edition of CS3. That is, I took a measurement (including the complete histogram) before and after a brightness adjustment and then compared the histograms in a spreadsheet. Yes, on average they moved as expected, but in detail they were quite different. So if you want to preserve the numerical values in your images as they are translated check out that behavior because I think you will be disappointed. For common photos it is fine, but for analysis it is lacking, in my opinion.

                             

                            This brings up something that would be useful if you are still searching for an answer - a more complete description of what you are trying to accomplish. For example, even if you manage to shift histograms, what is the next step ? Are you going to do a visual inspection ? how ? are you going to do a numerical anaylsis ? how ?  The extended version of Photoshop has some tools you might use, but depending on what you want to accomplish a program other than Photoshop may be warranted. If we knew what you were after and also had one sample image you might be surprised at what some of the forum folk can offer.  It frequently happens that a lot more information up front saves everyone, including you, time.

                             

                            Regards,

                            Paulo

                            • 11. Re: translate histogram
                              George Austin Level 2

                              Alexxxmg,

                               

                              Ffactory does not install automatically. Look for it on the CS3 disk under "Goodies". Copy the entire folder (10 or 12 files) to your CS3 Plug-ins folder. You must also copy the file MSVCRT10.DLL to your Adobe PhotoshopCS3 directory under Program Files.

                               

                               

                              Hope this works out for you.

                              • 12. Re: translate histogram
                                George Austin Level 2

                                Alexxxmg,

                                 

                                It is possible that you'll get the same return errors whether in FilterFactory or FilterFoundry because, perhaps, you are entering the code literally as I gave it.

                                 

                                Do not enter "x" "y" and "V". Enter their VALUES at the reference point you choose.

                                 

                                For example, if that point is at, say, x = 102 px, y 320 px and you wish to set the channel values there to be 64 for all images, enter the following in each r,g,b box:

                                 

                                 

                                put(src(102,320,0),0),get(0)-64+r

                                 

                                 

                                Since the images are grayscale, the r,g,b values are identical at any pixel site so I arbitrarily chose to use the r channel.

                                 

                                The first "0" identifies the r channel. It could as well have been 1 (green) or 2 (blue)

                                 

                                The second and third 0 identify the FF memory slot (there are 256 assignable)

                                 

                                The final "r" returns the actual red value at each pixel site. Again, it could as well have been "g" or "b". Here you do enter the variable, not a fixed value

                                 

                                 

                                I don't have Filter Foundry, but I think it unlikely that it's code would be any different in this instance