skip to Main Content

If we shift the hue by 2*pi/3, what will the R, G, B, histograms change?

How can I test this? I have access to photoshop, so is there a way to test this and find the answer?

3

Answers


  1. I do not think there is an generic answer to this as the result is dependent on the image colors present not just on R,G,B histograms. You need to:

    1. compute histograms
    2. convert RGB to HSV
    3. add hue and clamp it to angular interval
    4. convert back to RGB
    5. compute histograms

    I do not use photoshop but I think #1,#2,#4,#5 should be present there. the #3 should be there too (in some filter that manipulates brithness, gama etc) but hard to say if adding to hue will be clamped by only limiting angle or it will handle it as periodic value. In the first case you need to correct the results by:

    1. compute histograms
    2. convert to HSV
    3. clone result A to second image B
    4. add A.hue+=pi/3 and **B.hue-=2*pi/3

      the A holds un-clamped colors and B the colors that were clamped in A shifted to the correct hue posititon.

    5. in A recolor all pixels with hue==pi2 with some specified color

      the pi2 should be the value your tool clamped hues above pi2 so it can be zero, pi2 or one step less then pi2. This will allow as to ignore clamped values later.

    6. in B recolor all pixels with hue==0 with some specified color
    7. convert A,B to RGB
    8. compute histograms ignoring specified color
    9. merge the A,B histograms

      simply add the graph values together.

    And now you can compare the histograms to evaluate the change on some sample images.

    Anyway you can do all this in any programing language. For example most of the operations needed are present in most image processing and computer vision libs like OpenCV and adding to hue are just 2 nested for loops addition and single if statement like:

    for (y=0;y<ys;y++)
     for (x=0;x<xs;x++)
      {
      pixel[y][x].h+=pi2/3.0;
      if (pixel[y][x].h>=pi2)
       pixel[y][x].h-=pi2;
      }
    

    of coarse most HSV pixel formats I used does not use floating values so the hue could be represented for example by 8 bit unsigned integer in which case the code would look like:

    for (y=0;y<ys;y++)
     for (x=0;x<xs;x++)
      pixel[y][x].h=(pixel[y][x].h+(256/3))&255;
    

    If you need to implement the RGB/HSV conversions look here:

    I think this might interests you:

    Login or Signup to reply.
  2. Looking at it from a mathematical point of view 2×pi/3 with pi = 3.14 you have 2×pi which is the the “scope” of a circle.
    Devided by 3 that means you have a third of a circle or simply 120°

    Login or Signup to reply.
  3. According to HSV into RGB conversion formula (part of it):

    enter image description here

    Shifting HUE by 120° will swap channel histograms:

    • +120° : R–>G–>B–>R
    •  -120° : B<–R<–G<–B

    To test this in GIMP,- open image histogram in Colors Info Histogram.

    Choose Red,Green or Blue channel to see it’s histogram and then open dialog

    Colors Hue-Saturation and then adjust Hue by +- 120 degrees and see live effect in Histogram window.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search