Author Topic: Color Rescales in LaserBoy  (Read 13721 times)

0 Members and 1 Guest are viewing this topic.

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2130
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Color Rescales in LaserBoy
« on: April 22, 2010, 10:00:49 pm »
Has anybody tried this yet?

If you copy this into a text file in the LaserBoy/txt/rescales/ folder, you can set the file name in the LB TUI for each of the R, G, B & I color signals.

Files need to be ASCII, every table must start with a value of 0. This is to reinforce the connection between r = g = b = 0 is ALWAYS black because the laser must be off when there is zero volts on the modulation inputs of all the lasers.

All the numbers must also be even because in the binary form, the least significant bit needs to be open for the markers of end of frame, unique frame, and such.


Quote
#
# LaserBoy color rescale file
# This is a comment
# This example is linear


0
128
256
384
512
640
768
896
1024
1152
1280
1408
1536
1664
1792
1920
2048
2176
2304
2432
2560
2688
2816
2944
3072
3200
3328
3456
3584
3712
3840
3968
4096
4224
4352
4480
4608
4736
4864
4992
5120
5248
5376
5504
5632
5760
5888
6016
6144
6272
6400
6528
6656
6784
6912
7040
7168
7296
7424
7552
7680
7808
7936
8064
8192
8320
8448
8576
8704
8832
8960
9088
9216
9344
9472
9600
9728
9856
9984
10112
10240
10368
10496
10624
10752
10880
11008
11136
11264
11392
11520
11648
11776
11904
12032
12160
12288
12416
12544
12672
12800
12928
13056
13184
13312
13440
13568
13696
13824
13952
14080
14208
14336
14464
14592
14720
14848
14976
15104
15232
15360
15488
15616
15744
15872
16000
16128
16256
16384
16512
16640
16768
16896
17024
17152
17280
17408
17536
17664
17792
17920
18048
18176
18304
18432
18560
18688
18816
18944
19072
19200
19328
19456
19584
19712
19840
19968
20096
20224
20352
20480
20608
20736
20864
20992
21120
21248
21376
21504
21632
21760
21888
22016
22144
22272
22400
22528
22656
22784
22912
23040
23168
23296
23424
23552
23680
23808
23936
24064
24192
24320
24448
24576
24704
24832
24960
25088
25216
25344
25472
25600
25728
25856
25984
26112
26240
26368
26496
26624
26752
26880
27008
27136
27264
27392
27520
27648
27776
27904
28032
28160
28288
28416
28544
28672
28800
28928
29056
29184
29312
29440
29568
29696
29824
29952
30080
30208
30336
30464
30592
30720
30848
30976
31104
31232
31360
31488
31616
31744
31872
32000
32128
32256
32384
32512
32640

James.  :)
« Last Edit: April 22, 2010, 10:08:13 pm by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline BlinkenLights

  • he's just this guy, ya know?
  • Administrator
  • Hero Member
  • *****
  • Posts: 730
  • Milliwatts: 4
  • Gender: Male
  • 'The Messenger' by Will Cascio
    • View Profile
Re: Color Rescales in LaserBoy
« Reply #1 on: April 24, 2010, 02:17:11 am »
lost me

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2130
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Color Rescales in LaserBoy
« Reply #2 on: April 24, 2010, 02:44:26 pm »
Copy the quote and save it in a file called linear.txt. Put it in the LaserBoy/txt/rescales/ folder.

It will be available there for you to find from menu b option 6.

Once you have set your rescale files by name in the interface, you can save a wave and it will apply and save the rescales in the wave.

The rescale information above is linear. That means it is there, but it has no effect because the normal, one-to-one function for converting an unsigned byte color value into a signed short (16-bit) wave sample is (byte * 128 = short).

With a table of numbers like this, you could define your own relationship between the color byte values you get in a normal set of RGB values and the signed short integers that get stored in the wave samples.

If you have a laser with analog modulation that is not linear, you can compensate for it this way.

Since the rescale tables are stored in the header of the wave and they are both one-to-one and onto functional relationships, they can be undone.

So, even if you use color rescales to optimize your systems color linearity, you can share your waves with others and they can open them in LaserBoy, strip out the compensation for your system and put in their own, if they choose.

James.  :)
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline meandean

  • Sr. Member
  • ****
  • Posts: 466
  • Milliwatts: 13
  • It's about sight AND sound.
    • View Profile
Re: Color Rescales in LaserBoy
« Reply #3 on: April 24, 2010, 10:17:52 pm »
 It would be great if laser diode manufacturers were to provide correction tables in a standard format for their products,
but that's not likely to happen anytime soon. As it is, Windows has long supported ICM color management as a means to color
match monitors, scanners and printers in a meaningful way to some sort of standard using device specific profiles, but the
whole concept has more or less tanked in terms of practical implemetation.

 What makes you think that anyone would have the patience (or the time) to systematically hand-type 256 unique color
matching values in a text editor and experiment over and over until they got a pleasing visual result?

 Most graphic utilities have a complement of canned curve manipulations such as brightness, contrast, and gamma so that the
user can just pull a lever back and forth instead trying to micro-manage a numerical transfer table. If you really want to
get adventurous, some utilities provide a graph of the color map for each channel so that you can use your mouse to bow,
bend, and inflect the curve to your liking and see the result in real time (There I go with the GUI thing again).

Quote
So, even if you use color rescales to optimize your systems color linearity, you can share your waves with others and they can open them in LaserBoy, strip out the compensation for your system and put in their own, if they choose.


 As the angels wait, breathlessly.

« Last Edit: April 24, 2010, 11:33:10 pm by meandean »
"Patience is for the dead."

Offline BlinkenLights

  • he's just this guy, ya know?
  • Administrator
  • Hero Member
  • *****
  • Posts: 730
  • Milliwatts: 4
  • Gender: Male
  • 'The Messenger' by Will Cascio
    • View Profile
Re: Color Rescales in LaserBoy
« Reply #4 on: April 25, 2010, 11:52:43 pm »
true but the fact that laserboy CAN rescale in the way is a first step. its academic.

Offline meandean

  • Sr. Member
  • ****
  • Posts: 466
  • Milliwatts: 13
  • It's about sight AND sound.
    • View Profile
Re: Color Rescales in LaserBoy
« Reply #5 on: April 26, 2010, 08:53:32 pm »
Quote
Since the rescale tables are stored in the header of the wave and they are both one-to-one and onto functional relationships, they can be undone.


 How are these tables stored in the wave header (I would hope that it's not text)?
"Patience is for the dead."

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2130
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Color Rescales in LaserBoy
« Reply #6 on: April 26, 2010, 11:59:31 pm »
They are saved as 512K chunks, as in exactly (256)  signed 16-bit binary values.

Out of the 32 bit flags found in the wave mode of which you are already familiar, 4 bits are used to indicate the presence or absence of these tables at positions 9, 10, 11 & 12.

If any of the tables are present, they appear in logical order (after the LaserBoy wave mode).

Code: [Select]
#define    LASERBOY_WAVE_NEGATIVE                   0    // bit position
#define    LASERBOY_WAVE_POSITIVE                   1    // 0
#define    LASERBOY_WAVE_END_OF_FRAME               2    // 1
#define    LASERBOY_WAVE_UNIQUE_FRAME               4    // 2
#define    LASERBOY_WAVE_UNIQUE_VERTEX              8    // 3
#define    LASERBOY_WAVE_OFFSETS                    16   // 4
#define    LASERBOY_WAVE_OPTIMIZED                  32   // 5
#define    LASERBOY_WAVE_SIGNAL_MATRIX              64   // 6
#define    LASERBOY_SIGNAL_BIT_RESOLUTION           128  // 7
#define    LASERBOY_WAVE_NUM_FRAMES                 256  // 8
#define    LASERBOY_COLOR_RESCALE_R                 512  // 9
#define    LASERBOY_COLOR_RESCALE_G                 1024 // 10
#define    LASERBOY_COLOR_RESCALE_B                 2048 // 11
#define    LASERBOY_COLOR_RESCALE_I                 4096 // 12

The reason the individual import tables are in plain ASCII is so that it is possible to read and write them 'by-hand' and perhaps, with a bit more imagination, you might be able to write them from your own application.

James.
« Last Edit: April 27, 2010, 12:10:15 am by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

Offline meandean

  • Sr. Member
  • ****
  • Posts: 466
  • Milliwatts: 13
  • It's about sight AND sound.
    • View Profile
Re: Color Rescales in LaserBoy
« Reply #7 on: April 27, 2010, 12:54:00 am »
  Let's say that the wave has offset values in the header- does this color table stuff appear before the offsets are defined?
Simply put, do the color tables (when present) immediately follow the 32bit flag?
"Patience is for the dead."

Offline James

  • Administrator
  • Hero Member
  • *****
  • Posts: 2130
  • Milliwatts: 47
  • Gender: Male
    • View Profile
    • LaserBoy !!!
Re: Color Rescales in LaserBoy
« Reply #8 on: April 27, 2010, 01:04:42 am »
No. Each of the possible extra chunks that might appear after the mode value appear in the order in which they appear in that list, from offsets on...

This means you need to know the size of all of the chunks that might precede it.

Code: [Select]
        sub_chunk_1_size += (   16 // sizeof "LaserBoymmddCCYY"
                              + sizeof(int) // sizeof (int)LaserBoy_wave_mode
                              + (   (LaserBoy_wave_mode & LASERBOY_WAVE_OFFSETS)
                                  ? (num_channels * sizeof(int))
                                  : (0)
                                )
                              + (   (LaserBoy_wave_mode & LASERBOY_WAVE_OPTIMIZED)
                                  ? (7 * sizeof(int)) // seven 32bit numbers
                                  : (0)
                                )
                              + (   (LaserBoy_wave_mode & LASERBOY_WAVE_SIGNAL_MATRIX)
                                  ? (num_channels * 2 * sizeof(short))
                                  : (0)
                                )
                              + (   (LaserBoy_wave_mode & LASERBOY_SIGNAL_BIT_RESOLUTION)
                                  ? (num_channels * sizeof(u_char))
                                  : (0)
                                )
                              + (   (LaserBoy_wave_mode & LASERBOY_WAVE_NUM_FRAMES)
                                  ? (sizeof(int))
                                  : (0)
                                )
                              + (   (LaserBoy_wave_mode & LASERBOY_COLOR_RESCALE_R)
                                  ? (256 * sizeof(short))
                                  : (0)
                                )
                              + (   (LaserBoy_wave_mode & LASERBOY_COLOR_RESCALE_G)
                                  ? (256 * sizeof(short))
                                  : (0)
                                )
                              + (   (LaserBoy_wave_mode & LASERBOY_COLOR_RESCALE_B)
                                  ? (256 * sizeof(short))
                                  : (0)
                                )
                              + (   (LaserBoy_wave_mode & LASERBOY_COLOR_RESCALE_I)
                                  ? (256 * sizeof(short))
                                  : (0)
                                )
                            );

In C, there is a thing called the turnery operator in the form of

expression = condition ? true_value : false_value;

It is the only operator that takes three arguments!

Each one of these tests the value of LaserBoy_wave_mode & (bitwise AND) a value from the mode bits list.

Look at the function:

void LaserBoy_wave_header::to_fstream_wave(fstream& out) const

on line 493 in LaserBoy_wave.cpp.

James.

PS ...... because I want to make you read C++!
« Last Edit: April 27, 2010, 01:29:39 am by James »
LaserBoy is Sofa King Cool!
But it will never be Alpha King Done!

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.7 © 2008-2024, SimplePortal