• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Convert Red Channel to Grayscale maintaining exact values

Community Beginner ,
May 12, 2023 May 12, 2023

Copy link to clipboard

Copied

Hi guys, I got an RGB image which I want to convert to grayscale but maintaining exact grayscale values that were initially in Red channel, namely these 43, 33, 76 and 66. I tried using Grayscale Conversion node with Red channel weight set to 1 while having Green and Blue set to 0, but it still doesn't work and the resulting grayscale image has incorrect values:

Nitroleum_0-1683881110233.png

 

 

Here's the source RGB image in case you want to give it a try yourself. I'm trying to convert it to a grayscale single channel image:

Test_RGB.png

 

Is there a way how to do it in SD? Thanks!

TOPICS
How to

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , May 12, 2023 May 12, 2023

I think there's a few things going on, your working in 8 bit and if it's 33-34 I would guess it's a rounding error where it's converting internally and rounds down/up, I did my test in 16bit and it was more accurate, might be that.  also I think the test file is in RGB and gets exported in RGB (gamma curve on it) and gets exported as that so if I treat it like data and do linear encoding in game engine it's way off,  you can force linear in export to compensate and test that.

Also when I do that

...

Votes

Translate

Translate
Participant ,
May 12, 2023 May 12, 2023

Copy link to clipboard

Copied

 

I use rgba split to get access to the channels seems to keep base value doing that, saying that i tried doing it how you approached it and got the correct values as well so not sure whats going on with yours, it's usually where a gamma curve gets applied rather than being in linear space that messes with any values but I can't recreate that.  Hovering over will show the normalised float value in 0-1 range but if you look at v where i'm hovering over 76 in the 0-255 range it maps correctly

 

Mark_Edwards_0-1683881417671.png

 

Mark_Edwards_1-1683881903853.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 12, 2023 May 12, 2023

Copy link to clipboard

Copied

Yes v parameter shows correct values but unfortunately it's of no use for me as grayscale actual values are quite significantly off which is a no go for me..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 12, 2023 May 12, 2023

Copy link to clipboard

Copied

where are you seeing that the value is off, happy to try and recreate, I use specific values quite a bit in my graphs and haven't run into that issue but perhaps it's something different.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 12, 2023 May 12, 2023

Copy link to clipboard

Copied

The thing is I use this texture inside of Unreal Engine which epects exact grayscale value, so for example if it will not be 33 but let's say 34 - my set up won't work.

 

If you will export your file using that RGB split node you will see that grayscale values will be quite far off which is a no go for me unfortunately.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 12, 2023 May 12, 2023

Copy link to clipboard

Copied

LATEST

I think there's a few things going on, your working in 8 bit and if it's 33-34 I would guess it's a rounding error where it's converting internally and rounds down/up, I did my test in 16bit and it was more accurate, might be that.  also I think the test file is in RGB and gets exported in RGB (gamma curve on it) and gets exported as that so if I treat it like data and do linear encoding in game engine it's way off,  you can force linear in export to compensate and test that.

Also when I do that sort of thing I build in a bit of tolerance in what I was looking for so its ~77 or make the epsilon value a bit larger if you are comparing a float in the game engine to account for rounding errors. 

Or it's something else 🙂

Mark_Edwards_0-1683888400373.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines