16 Replies Latest reply on Feb 7, 2013 7:18 PM by MikeKPhoto

    Why does Photoshop consider 0 divided by 0 to be 0?

    conroy Level 5

      Why does Photoshop reckon 0 divided by 0 is 0 when doing arithmetic with colour components?

       

      I guess the program logic assumes 0 divided by anything is 0, never proceeding as far as considering that a divisor of 0 is involved. But I wonder if this handling of 0 / 0 is deliberate for a reason that eludes me.

       

      For a non-zero number divided by 0, Photoshop produces the maximum value of a colour component (e.g. 255 in 8 bits). That is sensible and the same result should arise from dividing 0 by 0, surely. (Other graphics software does consider 0 / 0 to produce max.)

       

      Look at the contrived example below. The black disc in Divide mode should result in a white disc, but wherever an underlying colour component is 0, the resulting colour component is 0 instead of max. (Don't bother measuring the pixels in the screenshot - they've been converted from sRGB to my display profile then to sRGB again without infinite precision.)

       

      Screen-shot-2013-02-07-at-13.57.03.png

        • 1. Re: Why does Photoshop consider 0 divided by 0 to be 0?
          Noel Carboni Level 8

          Interesting thoughts.

           

          Whenever exploring limits of software, I tend to think about what happens BETWEEN and NEAR the limits. 

           

          As a test I created a document along the lines of what you did, then added a Curves layer clipped to the Gradient fill layer.  I noted the behavior of the result as I made the gradient layer darker.  The output stayed maxed-out right up until the curves reached zero (meaning all the pixel data passed up to the layer with Divide blending were (0, 0, 0), at which point the result just went to black, confirming what you're seeing.

           

           

           

          Then I tried setting the color of the layer with Divide blending to a little above black (non-zero).

           

           

          Note the consistency between these results, both creating maxed-out colors and ending up at black once the layers below delivered (0, 0, 0) pixel values.

           

          These things came to mind:

           

          Since 0/0 is undefined, mathematically (it becomes a philosophical question leading ultimately to brain freeze in the cold vacuum of space ), an exception must be chosen.

           

          Which of these does Adobe choose?

           

          • Anything divided by 0 is infinite.
          • 0 divided by anything is 0.

           

          Is there a reason they have to choose just one?  It's a computer, after all, and can make decisions.  Maybe they made choices based on what made for the most interesting results, artistically.  Maybe it's actually something in between that seems to make artistic sense.

           

          -Noel

          • 2. Re: Why does Photoshop consider 0 divided by 0 to be 0?
            conroy Level 5

            Which of these does Adobe choose?

             

            • Anything divided by 0 is infinite.
            • 0 divided by anything is 0.

             

             

             

            Anything divided by 0 is infinite, of course, but since finite-valued colour components are the consideration, and not philosophy, the max value of a component should be substituted when a result is infinity.

             

            Furthermore, Photoshop does do the substitution, except for one specific anomaly: 0 divided by 0, where Photoshop produces 0 and other software, sensibly and consistently produces max value.

             

            Is there a reason they have to choose just one?  It's a computer, after all, and can make decisions.  Maybe they made choices based on what made for the most interesting results, artistically.  Maybe it's actually something in between that seems to make artistic sense.

             

            A mistake in Photoshop's logic makes far more sense to me than that. Maybe you are just being contrary today.

            • 3. Re: Why does Photoshop consider 0 divided by 0 to be 0?
              Level 7

              0/0 is not always considered infinite: (sin(x)/x) -> 1 as x -> +-0.

              (a function Noel should be familiar with :-)

               

               

              And as Noel guessed, the choice is by design because in many instances it provides better continuity in the visual results.

              • 4. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                conroy Level 5

                Here is an image divided by itself. The result should be solid white but because Photoshop produces 0 when dividing 0 by 0, the result is sprinkled with artefacts.

                 

                Screen shot 2013-02-07 at 18.17.53.png

                • 5. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                  conroy Level 5

                  Chris Cox wrote:

                   

                  0/0 is not always considered infinite: (sin(x)/x) -> 1 as x -> +-0.

                  (a function Noel should be familiar with :-)

                   

                   

                  And as Noel guessed, the choice is by design because in many instances it provides better continuity in the visual results.

                   

                  0/0 can be considered infinite or 1, but you deliberately chose 0 because you prefer the visual result in some cases. Yeah, right, sure you did.

                   

                  P.S. Please stop mucking around with the marking of posts as correct or helpful.

                  • 6. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                    Noel Carboni Level 8

                    Actually, I specifically said 0/0 is undefined, not "infinite".  Perhaps I should have said "indeterminate" or "NaN".  But I do support your artistic choice in this case, Chris.

                     

                    Conroy, think of it as a "channel clipping detector". 

                     

                    -Noel

                    • 7. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                      Level 7

                      Depending on the context, 0/0 can be considered zero, one, positive infinity or negative infinity.

                      It depends on the specific context and what you are trying to provide continuity with.

                       

                       

                      P.S. I'm not the only admin here.

                      • 8. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                        conroy Level 5

                        Noel Carboni wrote:

                         

                        Conroy, think of it as a "channel clipping detector". 

                         

                         

                        Nope, I'll continue to think of it as a mistake.

                         

                        Whenever I need the "correct" result, I'll use other software.

                        • 9. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                          conroy Level 5

                          Chris Cox wrote:

                           

                          P.S. I'm not the only admin here.

                           

                          True, but at the very moments of your being active in the forum, "administration" happens to posts in threads in which I'm active, and the "administration" doesn't happen when you're not active in the forum. Must be a multitude of coincidences.

                          • 10. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                            Level 7

                            I'm active in the forums almost all day, even when not posting here.

                            • 11. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                              Noel Carboni Level 8

                              conroy wrote:

                               

                              Noel Carboni wrote:

                               

                              Conroy, think of it as a "channel clipping detector". 

                               

                               

                              Nope, I'll continue to think of it as a mistake.

                               

                               

                               

                              Suit yourself, but honestly in no place in the world would one interpretation of "zero divided by zero" be considered any more or less a "mistake" than others. 

                               

                              You seem to have the thought that Photoshop should be implemented per your idea of what makes sense.  In my thinking it's kind of like criticizing the designer of a socket wrench for not handling a particularly long bolt.  Your thought to use another tool for getting the results you need in a specialty situation - akin to using a socket wrench specificallly designed for deep operation - is reasonable.

                               

                              What application of "Divide" blending had you envisioned where you needed it to work in a different way than it actually does?  The obvious thing is to try to think of another way to do that operation.

                               

                              -Noel

                              • 12. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                                conroy Level 5

                                There are a great many occasions of my posts (and sometimes posts by other people in threads in which I'm active) being "administrated" in the very same minutes as you are actually posting in this forum, yet this tampering very rarely happens during the periods when you are not actively posting.

                                • 13. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                                  conroy Level 5

                                  Noel Carboni wrote:

                                   

                                  conroy wrote:

                                   

                                  Noel Carboni wrote:

                                   

                                  Conroy, think of it as a "channel clipping detector". 

                                   

                                   

                                  Nope, I'll continue to think of it as a mistake.

                                   

                                   

                                   

                                  Suit yourself, but honestly in no place in the world would one interpretation of "zero divided by zero" be considered any more or less a "mistake" than others.

                                   

                                  In graphics software other than Photoshop, 0 / 0 does not produce 0 in the context of colour component values. The production of max value is the usual result and it just happens to be a sensible result in the context of colour component values, to my way of thinking (which is often considered abnormal, I don't mind admitting).

                                   

                                   

                                   

                                  You seem to have the thought that Photoshop should be implemented per your idea of what makes sense.

                                   

                                  No, I certainly do not think Photoshop should be implemented according to my ideas. I would prefer it to be, of course. But preferring is far from expecting.

                                   

                                  Clearly, I'm not alone in thinking 0/0 shouldn't be 0 in this situation. I have other graphics software that produces max value when dividing any colour component value (including 0) by 0.

                                   

                                   

                                  What application of "Divide" blending had you envisioned where you needed it to work in a different way than it actually does?  The obvious thing is to try to think of another way to do that operation.

                                   

                                   

                                  I noticed the Photoshop anomaly when looking at mantralight's problem of increasing the whiteness of an image. Yes, there are other ways to do that, but I decided to post about the issue because Photoshop's result seemed like a mistake.

                                  • 14. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                                    Noel Carboni Level 8

                                    Clearly those other programs are doing it "wrong", considering which program is known to be the primo editing tool and sells for the big bucks.    We could go on and on.  Perhaps Adobe needs to create an alternate Divide mode (or better yet a "roll your own" blender).  Clearly they can't change something that may be built into millions of PSD files already.

                                     

                                    I never did figure out what mantralightroom wants from his whites.

                                     

                                    -Noel

                                    1 person found this helpful
                                    • 15. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                                      conroy Level 5

                                      I've marked reply #14 as Helpful. Thanks, Noel!

                                       

                                      I started the thread and find reply #14 to be a helpful response to my query. Another two responses keeps being marked Helpful by someone with administrative privileges. <Rolls eyes>Who might that be?</Rolls eyes> I'll have to keep unmarking them. My resolution of this evening to ignore damned interfering with the forum has failed already.

                                      • 16. Re: Why does Photoshop consider 0 divided by 0 to be 0?
                                        MikeKPhoto Level 2

                                        In my Advanced mathematics class (calculus) zero was defined as a number so small that it could not be measured, being the opposite of infinity which is a number so large it cannot be measured.

                                         

                                        So zero divided by zero could be anything.