Page 1 of 1

Adjusting 8bit to 'level' and compose properly into 16bit range

Posted: 2019-02-15T09:39:58-07:00
by LDAsh
This is more of a hypothesis looking for advice than an issue, since I'm not even sure where to begin...

I'm wanting to take a heap of grayscale 8-bit images and layer them on top of each other by using 'compose add' into a 16-bit grayscale, but I want to make sure those 256 colours are a consecutive 256 range of grays out of 65536. What I mean is, it should be a range like 0-255/65536 (instead of 256 steps of gray between each pixel), and when I use 'compose add' in 16-bit, 2 of them would equal a range of 512, 4 of them 1024, 8 of them 2048, etc.
Ideally the limit of layers to compose would be 8, so specifically I'm looking at trying to make sure the 256 range of 8-bit grays (0-255) equate to a 16-bit range of 0-8191 (a maximum gray equal to that of 32 in 8-bit), if my math is correct, that should mean 'compose add' on those 8 images would give me the full range of 16-bit from pure black to pure white. It should mean, what used to take 256 pixels to have unique columns/rows of grays could now be 2048 and still be unique, without any banding. My method to avoid banding would involve some blur and some roll offset of each image, which should do the trick.

So I guess the first step is converting my 8-bit grayscales to 16-bit and then adjusting the colour correctly, and since I can't see the result because everything I have is 32-bit display, I need some verbose output to see the amount of colours used and the range of brightness from lowest to highest value. I also need to lower my gamma/luminance by a 12.5% exactly after converting to 16-bit, but I'm not sure what I should be looking at since I don't want to plateau my black. Since there is no "luminance" literally I can only think of inverting the colours and then playing with gamma.

So first of all, any advice about getting that range of gray down to 12.5% without losing any information, that would be great. Based on my experience, it's really hard to find something that operates like the "luminance" method I'm used to in Paint Shop Pro, where it adjusts brightness with a bias on white over black, so black would never plateau and bleed out. I think "intensity" is what I'm after but that still goes over my head for now.

Secondly, once I have done that, how to exactly check that the image is okay since I can't actually see it? Just running it through identify seems to give me the min and max but still not entirely sure how to see the exact amount of unique colours used. If correct, I guess it should read "min: 0 (0), max: 8191 (12.5)", and if I can find out it's exactly 256 colours then all should be well. Then, after applying some blur, that amount of unqiue colours should boost from 255 to somewhere upward of 8000, and I'd be ready to roll and compose.

Thanks for any advice about this, I'm sure I'd still be here busy blindly toying with gamma/modulate/levels/etc.

Re: Adjusting 8bit to 'level' and compose properly into 16bit range

Posted: 2019-02-15T10:20:43-07:00
by snibgo
How about reading the grayscale (8-bit) inputs, then "-evaluate-sequence Mean", then write the (16-bit) output? That seems to do everything you want.

Of course, you can "-background None -compose Plus -layers flatten" to add the images to each other, then divide by whatever you want. Or do the division before the adding, which is mathematically the same but will take more time.

But I may misunderstand what you want.

Re: Adjusting 8bit to 'level' and compose properly into 16bit range

Posted: 2019-02-15T10:58:17-07:00
by LDAsh
I will look into those different approaches, but really the issue I'm having is the division itself. So far I am using "-level 0%,282.85%,0.5", which takes that 255/65536 gray and makes it just shy of 8192, according to identify. I have no idea why it's that percentage, but that's what I whittled it to. I would have thought 12.5% or 800% was what I'm after, but anyways...

This all almost does what I want, but I am losing so much off the lower spectrum and it is plateauing, unfortunately. I'm convinced I would be getting the whole range of grays otherwise, but, I'm losing too much in process using "level".

I uploaded everything so it might become clearer, but forgive me, I know it must be a hideous approach:-
http://www.violae.net/temp/IMgs8X16.zip
____________________________________________

Not sure how easy this might be to see for anyone else, but, this is the result from a basic linear gradient:-
Image

Re: Adjusting 8bit to 'level' and compose properly into 16bit range

Posted: 2019-02-15T17:22:31-07:00
by LDAsh
Ugh, I was under the impression I needed to use a combination of white AND gamma, but actually I only needed white-point, which indeed works out to 800%! I did learn a lot about other ways of adjusting colours and brightness by reading and playing with everything else, at least. :P

Still not sure how to count unique colours, but XnView can do that.

Re: Adjusting 8bit to 'level' and compose properly into 16bit range

Posted: 2019-02-15T17:27:15-07:00
by fmw42
Still not sure how to count unique colours, but XnView can do that.
That is what the histogram will do for you. See https://imagemagick.org/Usage/files/#histogram

Re: Adjusting 8bit to 'level' and compose properly into 16bit range

Posted: 2019-02-15T18:38:04-07:00
by snibgo
If you just want to count them:

Code: Select all

magick toes.png -unique-colors -format %w info:

62206

Re: Adjusting 8bit to 'level' and compose properly into 16bit range

Posted: 2019-02-15T20:24:19-07:00
by fmw42
Sorry, I thought he was asking about how many of each unique-color, not the count of unique colors.