Convert an Image to greyscale and its Histogram

Moderator: jsachs

Marpel
Posts: 288
Joined: September 13th, 2009, 3:19 pm
What is the make/model of your primary camera?: Nikon D810
Location: Port Coquitlam, British Columbia

Convert an Image to greyscale and its Histogram

Postby Marpel » July 7th, 2017, 6:22 pm

I have an image that is all blue tones in various values. I converted it to 16 bit greyscale (simply with the Convert tool, without any manual manipulation of the image at all). I then compared the histogram of both images (using the HSV-V default) and, surprisingly, found that they do not match, with the histogram of the greyscale image spreading farther to the left into the darker values. Prior to this operation, I just assumed that both histograms would be exact. Can anyone explain??

As a background (hopefully my explanation is understandable): I am trying to change the all-blue image into an all-yellow image (with a certain value/tone range). I have a colour chart of yellow tones that I am using as reference to pick the yellows from, however I found initial attempts unsuccessful, presumably because yellow is a much lighter colour than blue.

So I thought I would first convert both the blue image and the yellow chart to greyscale, then lighten the greyscale of the blue image to match the greyscale of the yellow image and then use the same operation to lighten the blue image so its values were more of a match with the yellow chart. I would then use Grey>Tint and reference the greyscale images to better place points along the scale. But there appears to be a discrepancy in the values between a colour image and its black and white partner.

Apart from my question above, I am open to suggestions on how to successfully complete this task.

Thanks,

Marv

jsachs
Posts: 780
Joined: January 22nd, 2009, 11:03 pm

Re: Convert an Image to greyscale and its Histogram

Postby jsachs » July 7th, 2017, 7:39 pm

The Convert transformation extracts the luminance of the image and not the HSV value. This produces the a natural effect as it mimics the relative sensitivity of the eye to different colors. Given that the formulas are different, I would not expect the HSV-V histogram would match the luminance histogram.
Jonathan Sachs
Digital Light & Color

jsachs
Posts: 780
Joined: January 22nd, 2009, 11:03 pm

Re: Convert an Image to greyscale and its Histogram

Postby jsachs » July 7th, 2017, 7:55 pm

You might try this:

1) Extract the blue channel from the blue image.

2) Combine the following 3 RGB channels: set both the R and G channels to the extracted blue channel and set the B channel to all black

This assumes you want the lightest possible tones to be pure yellow.

You could also do a Combine Channels in the HSL color space setting L to the extracted blue channel and setting the H channel to 16.7% and S to 100%. If you use HSL the darkest colors will be black and the lightest white.
Jonathan Sachs
Digital Light & Color

Marpel
Posts: 288
Joined: September 13th, 2009, 3:19 pm
What is the make/model of your primary camera?: Nikon D810
Location: Port Coquitlam, British Columbia

Re: Convert an Image to greyscale and its Histogram

Postby Marpel » July 7th, 2017, 11:47 pm

Thanks very much Jonathan.

I will give your suggestions a try.

Marv

den
Posts: 612
Joined: April 25th, 2009, 6:33 pm
What is the make/model of your primary camera?: Canon EOS-350D/Fuji X100T
Location: Birch Bay near Blaine, WA USA

Re: Convert an Image to greyscale and its Histogram

Postby den » July 8th, 2017, 12:11 am

...
Perhaps you could also consider using the Color Curves transform in either the HSV or HSL color space and adjust the Hue curve with a 'broken line' from blue to yellow or a straight horizontal line at yellow or 16.7% vertical... ...this way the Value or Lightness or Saturation channels will essentially remain unchanged as will their respective histograms...
Screenshot (2).jpg
Screenshot (2).jpg (197.1 KiB) Viewed 363 times

...den...

jsachs
Posts: 780
Joined: January 22nd, 2009, 11:03 pm

Re: Convert an Image to greyscale and its Histogram

Postby jsachs » July 8th, 2017, 7:56 am

Here is another method that has the advantage that it preserves the luminance of the original image:

1) extract the luminance channel of the blue image - or just convert it to B&W which does the same thing

2) tint the B&W image with the color line file below -- this runs from black to yellow up to the luminance of pure yellow (.907) and then from yellow to white to capture the remainder of the tonal range.

Since you cannot upload .cln files to the message board, just copy and paste the following text using Notepad or the editor of your choice and save it as Yellow.cln. Then you can load this file from the Opt button to the right of the color line in the Tint transformation.

Colorline 1.0
ncolors 3
color 0 0.0000 0.0000 0.0000 0.0000
transition 0 line rgb
color 1 0.9070 1.0000 1.0000 0.0000
transition 1 line rgb
color 2 1.0000 1.0000 1.0000 1.0000
end
Jonathan Sachs
Digital Light & Color

den
Posts: 612
Joined: April 25th, 2009, 6:33 pm
What is the make/model of your primary camera?: Canon EOS-350D/Fuji X100T
Location: Birch Bay near Blaine, WA USA

Re: Convert an Image to greyscale and its Histogram

Postby den » July 8th, 2017, 11:18 am

...
Yet another possibility utilizing the properties of the HSL color space where the Hue and Saturation plane is at a 50% toned Lightness...
1) click on Img0, the starting image, Extract and Convert to 24 or 48 bit color its Luminance channel...
2) click on Img0, using Color Curves in HSL, set L with a horizontal line curve: 0,50 to 100,50 and set H with a horizontal line curve: 0,16.7 to 100,16.7; leave S unchanged; click OK... ...this normalizes the H-yellowed and S channels to a 50% Lightness tone.
3) click on the resulting 2) image version and open Composite-Hardlight where Input = the resulting 2) image at 100% Amount and Overlay = the color Converted Luminance channel resulting from 1) at Amount = 100%... ...click Apply or OK
Screenshot (5).jpg
Screenshot (5).jpg (94.39 KiB) Viewed 346 times
Original Luminance and HSL-Saturation channel contrasts are essentially preserved.
...den...

P.S. Was curious. Did a comparison: left-original; center-cln file; right-Normalized HS-Luminance
Screenshot (6).jpg
Screenshot (6).jpg (210.25 KiB) Viewed 336 times

Marpel
Posts: 288
Joined: September 13th, 2009, 3:19 pm
What is the make/model of your primary camera?: Nikon D810
Location: Port Coquitlam, British Columbia

Re: Convert an Image to greyscale and its Histogram

Postby Marpel » July 9th, 2017, 1:38 pm

Thanks to both Den and Jonathan for the follow-up suggestions.

I did try the initial suggestions from Jonathan and, of the two, combining channels in HSL appeared to work the best, but not optimal as it seems to destroy some gentle tone gradations (may be user error). And I found trying to get the yellow colour I was seeking a bit tricky by moving the point along the slider in extremely small increments.

My quest continues. I will give the latest suggestions a try.

Regards,

Marv

jsachs
Posts: 780
Joined: January 22nd, 2009, 11:03 pm

Re: Convert an Image to greyscale and its Histogram

Postby jsachs » July 9th, 2017, 2:26 pm

One more suggestion -- use the Selective Color Correction transformation, click on the blue image to create a control point and drag it to yellow. You may have to remove the default pure blue control point as well.
Jonathan Sachs
Digital Light & Color

Marpel
Posts: 288
Joined: September 13th, 2009, 3:19 pm
What is the make/model of your primary camera?: Nikon D810
Location: Port Coquitlam, British Columbia

Re: Convert an Image to greyscale and its Histogram

Postby Marpel » July 9th, 2017, 8:33 pm

I have tried all the suggestions, with the following results:

The color curves - could not get a "clean" yellow, no matter how hard I tried and where I moved the point(s). The results were similar to the "muddy" green (or whatever the color is) that shows in Den's example of the sky and eagle.

Building the colorline with data provided by Jonathan - this was, by far, the closest to what I was looking for. However, the initial attempt was too "blocked up" and destroyed the subtle transitions in darker areas. I tried reducing the contrast of the extracted black and white image first (by using Levels and Color and moving the left point to the right), then moving the Tint point 2 to the left until it looked good. This result was pretty darn good.

So, a couple questions:

What is the reason for performing the Grey>Tint on the black and white image rather than the original blue image?

Am I right in assuming that the "blocking up" of the yellow color is because the extreme difference in the tone of blue versus yellow (as in yellow is way lighter than the blue I am trying to work with)? This would suggest that, to do a color change like I am trying, the original image needs to have an appropriate tonal range to suit the intended outcome?

I have only ever built a colorline file by placing points along the slider and not by way of your provided description, which seems more accurate. Is there a tutorial on how to build these colorline files from scratch? I think I get the general gist but where do you get the numbers, like 0.9070, from? Is there a table that you pull them from or??

Thanks again to both Jonathan and Den,

Marv


Return to “Picture Window Support”

Who is online

Users browsing this forum: No registered users and 1 guest