Hald CLUT

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
stupid
Posts: 51
Joined: 2010-02-12T07:30:34-07:00
Authentication code: 8675308

Re: Hald CLUT

Post by stupid »

I can't test PS I'm away from where I normally am. I just downloaded FastStone Image Viewer, tested, and have a similar huge file.

s.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hald CLUT

Post by snibgo »

Repeating fmw's tests on Windows 8.1, IM v6.8.8-0, I get much the same file sizes. I suppose the issue is with XnView (whatever that is).
snibgo's IM pages: im.snibgo.com
stupid
Posts: 51
Joined: 2010-02-12T07:30:34-07:00
Authentication code: 8675308

Re: Hald CLUT

Post by stupid »

This line is the clue:

png:pHYs: x_res=2834, y_res=2834, units=1

The density is way over. If it's adjusted the file size drops to normal. Obviously not IM's problem but worth knowing. -density is the same as dpi isn't it?

s.
stupid
Posts: 51
Joined: 2010-02-12T07:30:34-07:00
Authentication code: 8675308

Re: Hald CLUT

Post by stupid »

Nope. Wrong again. Back where I started. Any information would be appreciated but I won't hold my breath. Thanks.

s.
patdavid
Posts: 8
Joined: 2013-09-04T08:05:59-07:00
Authentication code: 6789

Re: Hald CLUT

Post by patdavid »

stupid wrote:Nope. Wrong again. Back where I started. Any information would be appreciated but I won't hold my breath. Thanks.

s.
I'm not 100% sure, but I have been playing with these hald cluts for a while now, so I feel your pain about file size! :)

I do have a theory about the identity hald clut file size, though.

Along any of the 3 dimensions that describe the hald clut, the values at each successive location are monotonically increasing. That is, along the red dimension the value for red only increases by 1 at each increment. The same for each of the other channels.

As such, the compression algorithm exploits this fact and is able to very, very efficiently compress the image. If you apply any sort of color modification to the values, particularly ones that apply across all the range of values, that efficiency gets lost, and your file size balloons.

Open the identity clut, modify just a few pixels in some way, re-export and you'll see a slight change in image size. Even if you start modifying blocks of the clut, the filesize will stay reasonable.

Now open the identity clut, and change hue/sat across the entire image. You should see the file size jump quite a bit...
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: Hald CLUT

Post by rossdv8 »

I'm new to using HALD CLUT for processing, but reading this I just looked at my own LUTs again.

Using Fred's sugestion when he was helping me explore HALD CLUT, creating a new hald_8.png was 10.4Kb in Linux. I decided to create hald_16.png and got a CLUT of 172.8Kb.

So it seems the size change is exponential. That makes sense to me at any rate.

I then took a 1.5Mb jpeg to GIMP and applied saturation, an S-curve and changed gamma and levels. I sved it to PNG format. The 1.5Mb jpeg becomes a 10Mb PNG.

I applied those same modifications to my hald_16.png CLUT using GIMP and it jumped from 172.8Kb to 7.6Mb. That is just the table image with the same settings applied as I did to the jpeg before.

So I applied the 7.6Mb CLUT to my 1.5Mb jpeg using IM, and got an output png of 11.5Mb. only 1.5Mb bigger than doing the job in GIMP.

Now, out of curiosity I just used IM to apply more or less the same saturation, s-curve and gamma and some levels to that same 1.5Mb jpeg.

The output PNG was 9.9Mb.

So GIMP alone, IM just using convert commands and IM applying HALD-CLUT all output similar files sizes in the end.

So to me it looks like your original hald_16.png jumping to what seems a huge size appears pretty normal and has little effect on the eventual size of the output file.

I'm not an expert, but I thought trying all methods side by side was one way to see if there is something wrong.

Cheers,

RossD.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Hald CLUT

Post by fmw42 »

The size of the hald image should not affect the size of the processed image using -hald-clut by much if at all. The size of the hald image will create a more accurate color result, which might make the output slightly larger.

The file sizes could be affected by profiles and other meta data.

IM will not add a profile if it does not exist, unless you use -profile. But when using GIMP, it probably assigns a profile to an image. So that could case slightly different size results. If you are using PNG for an output format, the version of libpng might also affect the file size as it adds meta data.

Then there could be differences in optimizing the PNG. IM may not produce the best optimization compared to GIMP. Other tools such as pngcrush might optimize the results from IM better.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: Hald CLUT

Post by rossdv8 »

I think my experiment backs up what Fred says.

Original jpeg - 1.5Mb
Apply adjustments in GIMP and output as PNG - 10Mb
Apply similar adjustments using -convert in IM and output PNG - 9.9Mb
Apply adjustments to Hald 16 then apply to jpeg using IM and output PNG - 11.5Mb

I use a couple of different cameras and each imposes its own interpretation of the same scene.

I created a different HALD-CLUT for each camera according to GIMP modifications of images taken only seconds apart of the same scene with both cameras. Now I can easily get a standard across the cameras, by applying that camera's CLUT to an image taken with it.

Imagemagick saves a hell of a lot of time now I am learning about HALD-CLUT methods.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Hald CLUT

Post by fmw42 »

It does seem a bit odd that the Hald result is about 15% larger than the other two.

What output size do you get if you use a Hald:8 rather than Hald:16?
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: Hald CLUT

Post by rossdv8 »

Sorry Fred, I was off doing stuff with JoaCHIP's oil painting code from 2009. Amazing what we can find on here.

I'm using exactly the same image as i used in the previous post.

Hald-16 was 172.8Kb
Hald-16 became 7.6Mb after adjusting in GIMP

Hald-8 was 10.4Kb
Hald-8 became 205.1Kb after adjusting in GIMP

Original jpeg - 1.5Mb
Apply adjustments in GIMP and output as PNG - 10Mb
Apply similar adjustments using -convert in IM and output PNG - 9.9Mb
Apply adjustments to Hald 8 then apply to jpeg using IM and output PNG - 11.4Mb

So there is about 7.4Mb difference between adjusted hald-8 and hald-16, but the hald-8 output PNG is only about 100Kb smaller.

I did double check the files. All my hald-8 stuff is in a separate folder, so I can't mix them up no matter what I do.

Cheers,

RossD.
Post Reply