// // time: Fri Aug 30 14:11:24 1996 // // version: 3.0.0 (format), 3.1.2 (DX) // // // Begin MDF // MODULE BandColormap // CATEGORY Miscellaneous // DESCRIPTION Bands a colormap based on banding values // INPUT colormap; object; (none); // INPUT values; value list or field; (none); // INPUT remap; object; "low"; // OUTPUT output_1; field; // End MDF // // comment: Macro BandColormap // comment: ------------------ // comment: // comment: Category: Miscellaneous // comment: // comment: (C) Duncan Galloway 23/5/96 // comment: duncang@ibm590.aims.gov.au // comment: // comment: This macro converts a continuous colormap to a banded colormap given the banding values and the remap option. Because the colormap data is 3-vector the Band module cannot be used, not even if you convert the 3-vector colours to 1-vectors and do it that way. What seemed like a simple thing actually became a very difficult task which has necessitated some heavy thinking to come up with a solution which would work. // comment: // comment: I'm particularly pleased with this module because I first tried it over 1 year ago and gave up because it seemed too hard. // comment: // comment: One limitation with this module is that the band values must be sorted, min..max. If you do it any other way you will get an error. I want to come up with an array sorting macro soon but I have a headache right now. (See modification list) // comment: // comment: Another limitation is that the results will be unpredictable if the band values don't encompass the colormap fully. The ideal situation is to have banding values which include the minimum and maximum of the colormap. I did introduce some code to add these values if they weren't there, and this code works well if you have for example input from a scalar list module, but it doesn't work if you're using input from an Enumerate module for example (something to do with trying to add elements using the List module). // comment: // comment: This macro relies on one other macro, ArrayDouble, which converts an array a(1), a(2), ... a(n) to an array, double the size, with members like this: a(1), a(1), a(2), a(2), a(3), a(3), ... a(n), a(n). I needed this to do some of the more complicated stuff which was required to do the banding. // comment: // comment: Modification list // comment: ------------- // comment: // comment: 21/8/96 // comment: - Converted to DX version 3.1.2. // comment: - Added Sort module to sort values. // comment: - There was a problem with using the Enumerate module to generate a list of numbers to use in this module. Results from Enumerate are 1-vectors, not scalars, and this causes an error in the macro. The problem is solved by selecting the zeroth component of the band values after they are input to the macro. This works with scalar data also (I checked). // workspace: width = 1107, height = 845 // layout: snap = 0, width = 50, height = 50, align = UL // macro BandColormap( colormap ,values ,remap = "low" ) -> ( output_1 ) { // // node Input[6]: x = 28, y = 24, inputs = 0, label = Input // parameter: position = 2, name = 'values', value = '(none)', descriptive = 1, description = ' ', required = 1, visible = 1 // BandColormap_Input_6_out_1 = values; // // node Input[5]: x = 213, y = 41, inputs = 0, label = Input // parameter: position = 1, name = 'colormap', value = '(none)', descriptive = 1, description = ' ', required = 1, visible = 1 // BandColormap_Input_5_out_1 = colormap; // // node Compute[25]: x = 23, y = 106, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "$0.0" // expression: value = a.0 // name[2]: value = a // name[3]: value = b // BandColormap_Compute_25_out_1 = Compute( "$0.0", BandColormap_Input_6_out_1, NULL ) [instance: 25, cache: 1]; // // node Sort[1]: x = 30, y = 181, inputs = 2, label = Sort // BandColormap_Sort_1_out_1 = Sort( BandColormap_Compute_25_out_1, NULL ) [instance: 1, cache: 1]; // // node Transmitter[10]: x = 28, y = 260, inputs = 1, label = values // values = BandColormap_Sort_1_out_1; // // node Receiver[18]: x = 691, y = 63, inputs = 1, label = values // BandColormap_Receiver_18_out_1 = values; // // node ArrayDouble[1]: x = 527, y = 166, inputs = 1, label = ArrayDouble // BandColormap_ArrayDouble_1_out_1 = ArrayDouble( BandColormap_Receiver_18_out_1 ) [instance: 1, cache: 1]; // // node Extract[5]: x = 555, y = 333, inputs = 2, label = Extract // input[2]: defaulting = 0, visible = 1, type = 32, value = NULL // BandColormap_Extract_5_out_1 = Extract( BandColormap_ArrayDouble_1_out_1, NULL ) [instance: 5, cache: 1]; // // node Inquire[2]: x = 638, y = 160, inputs = 3, label = Inquire // input[2]: defaulting = 0, visible = 1, type = 32, value = "counts" // BandColormap_Inquire_2_out_1 = Inquire( BandColormap_Receiver_18_out_1, "counts", NULL ) [instance: 2, cache: 1]; // // node Compute[17]: x = 639, y = 236, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "$0*2-2" // expression: value = a*2-2 // name[2]: value = a // BandColormap_Compute_17_out_1 = Compute( "$0*2-2", BandColormap_Inquire_2_out_1 ) [instance: 17, cache: 1]; // // node Enumerate[2]: x = 628, y = 328, inputs = 5, label = Enumerate // input[1]: defaulting = 0, visible = 0, type = 29, value = 1 // input[2]: visible = 0 // input[4]: defaulting = 0, visible = 0, type = 29, value = 1 // input[5]: visible = 0 // BandColormap_Enumerate_2_out_1 = Enumerate( 1, NULL, BandColormap_Compute_17_out_1, 1, NULL ) [instance: 2, cache: 1]; // // node Select[3]: x = 607, y = 413, inputs = 3, label = Select // BandColormap_Select_3_out_1 = Select( BandColormap_Extract_5_out_1, BandColormap_Enumerate_2_out_1, NULL ) [instance: 3, cache: 1]; // // node Compute[18]: x = 668, y = 413, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "($0==1)||($0==$1)?0:1-($0%2)*2" // expression: value = (a==1)||(a==b)?0:1-(a%2)*2 // name[2]: value = a // name[3]: value = b // BandColormap_Compute_18_out_1 = Compute( "($0==1)||($0==$1)?0:1-($0%2)*2", BandColormap_Enumerate_2_out_1, BandColormap_Compute_17_out_1 ) [instance: 18, cache: 1]; // // node Statistics[1]: x = 440, y = 167, inputs = 1, label = Statistics // output[1]: visible = 0 // output[2]: visible = 0 // output[3]: visible = 0 // BandColormap_Statistics_1_out_1, BandColormap_Statistics_1_out_2, BandColormap_Statistics_1_out_3, BandColormap_Statistics_1_out_4, BandColormap_Statistics_1_out_5 = Statistics( BandColormap_Receiver_18_out_1 ) [instance: 1, cache: 1]; // // node Compute[22]: x = 437, y = 260, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "($1-$0)/200.0" // expression: value = (b-a)/200.0 // name[2]: value = a // name[3]: value = b // BandColormap_Compute_22_out_1 = Compute( "($1-$0)/200.0", BandColormap_Statistics_1_out_4, BandColormap_Statistics_1_out_5 ) [instance: 22, cache: 1]; // // node Transmitter[9]: x = 458, y = 345, inputs = 1, label = eps // eps = BandColormap_Compute_22_out_1; // // node Receiver[17]: x = 749, y = 412, inputs = 1, label = eps // BandColormap_Receiver_17_out_1 = eps; // // node Compute[20]: x = 639, y = 507, inputs = 4, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "[$0-$1*$2]" // expression: value = [a-b*c] // name[2]: value = a // name[3]: value = b // name[4]: value = c // BandColormap_Compute_20_out_1 = Compute( "[$0-$1*$2]", BandColormap_Select_3_out_1, BandColormap_Compute_18_out_1, BandColormap_Receiver_17_out_1 ) [instance: 20, cache: 1]; // // node Transmitter[8]: x = 731, y = 331, inputs = 1, label = nminus2 // nminus2 = BandColormap_Compute_17_out_1; // // node Receiver[14]: x = 731, y = 514, inputs = 1, label = nminus2 // BandColormap_Receiver_14_out_1 = nminus2; // // node Transmitter[11]: x = 263, y = 141, inputs = 1, label = colormap // colormap = BandColormap_Input_5_out_1; // // node Receiver[19]: x = 842, y = 64, inputs = 1, label = colormap // BandColormap_Receiver_19_out_1 = colormap; // // node Map[6]: x = 833, y = 153, inputs = 4, label = Map // BandColormap_Map_6_out_1 = Map( BandColormap_Receiver_18_out_1, BandColormap_Receiver_19_out_1, NULL, NULL ) [instance: 6, cache: 1]; // // node ArrayDouble[2]: x = 807, y = 240, inputs = 1, label = ArrayDouble // BandColormap_ArrayDouble_2_out_1 = ArrayDouble( BandColormap_Map_6_out_1 ) [instance: 2, cache: 1]; // // node Extract[6]: x = 823, y = 316, inputs = 2, label = Extract // input[2]: defaulting = 0, visible = 1, type = 32, value = NULL // BandColormap_Extract_6_out_1 = Extract( BandColormap_ArrayDouble_2_out_1, NULL ) [instance: 6, cache: 1]; // // node CollectNamed[1]: x = 901, y = 155, inputs = 4, label = CollectNamed // input[1]: defaulting = 0, visible = 0, type = 67108863, value = 0 // input[2]: defaulting = 0, visible = 0, type = 32, value = "low" // input[3]: defaulting = 0, visible = 0, type = 67108863, value = 2 // input[4]: defaulting = 0, visible = 0, type = 32, value = "high" // BandColormap_CollectNamed_1_out_1 = CollectNamed( 0, "low", 2, "high" ) [instance: 1, cache: 1]; // // node Input[7]: x = 341, y = 35, inputs = 0, label = Input // parameter: position = 3, name = 'remap', value = '"low"', descriptive = 0, description = ' ', required = 0, visible = 1 // BandColormap_Input_7_out_1 = remap; // // node Transmitter[12]: x = 344, y = 157, inputs = 1, label = remap // remap = BandColormap_Input_7_out_1; // // node Receiver[20]: x = 1035, y = 143, inputs = 1, label = remap // BandColormap_Receiver_20_out_1 = remap; // // node Select[5]: x = 952, y = 247, inputs = 3, label = Select // BandColormap_Select_5_out_1 = Select( BandColormap_CollectNamed_1_out_1, BandColormap_Receiver_20_out_1, NULL ) [instance: 5, cache: 1]; // // node Receiver[16]: x = 1046, y = 244, inputs = 1, label = nminus2 // BandColormap_Receiver_16_out_1 = nminus2; // // node Enumerate[3]: x = 953, y = 330, inputs = 5, label = Enumerate // input[2]: visible = 0 // input[4]: defaulting = 0, visible = 0, type = 29, value = 1 // input[5]: visible = 0 // BandColormap_Enumerate_3_out_1 = Enumerate( BandColormap_Select_5_out_1, NULL, BandColormap_Receiver_16_out_1, 1, NULL ) [instance: 3, cache: 1]; // // node Select[4]: x = 817, y = 413, inputs = 3, label = Select // BandColormap_Select_4_out_1 = Select( BandColormap_Extract_6_out_1, BandColormap_Enumerate_3_out_1, NULL ) [instance: 4, cache: 1]; // // node Construct[7]: x = 732, y = 608, inputs = 4, label = Construct // input[1]: defaulting = 0, visible = 1, type = 16777224, value = {[0]} // input[2]: defaulting = 0, visible = 1, type = 16777224, value = {[1]} // BandColormap_Construct_7_out_1 = Construct( {[0]}, {[1]}, BandColormap_Receiver_14_out_1, BandColormap_Select_4_out_1 ) [instance: 7, cache: 1]; // // node Replace[1]: x = 680, y = 696, inputs = 4, label = Replace // input[3]: defaulting = 0, visible = 1, type = 32, value = "positions" // input[4]: defaulting = 0, visible = 1, type = 32, value = "positions" // BandColormap_Replace_1_out_1 = Replace( BandColormap_Compute_20_out_1, BandColormap_Construct_7_out_1, "positions", "positions" ) [instance: 1, cache: 1]; // // node Output[3]: x = 700, y = 782, inputs = 1, label = Output // parameter: position = 1, name = 'output_1', value = ' ', descriptive = 0, description = ' ', required = 0, visible = 1 // output_1 = BandColormap_Replace_1_out_1; // network: end of macro body } BandColormap_Input_6_out_1 = NULL; BandColormap_Input_5_out_1 = NULL; BandColormap_Compute_25_out_1 = NULL; BandColormap_Sort_1_out_1 = NULL; BandColormap_Transmitter_10_out_1 = NULL; BandColormap_Receiver_18_out_1 = NULL; BandColormap_ArrayDouble_1_out_1 = NULL; BandColormap_Extract_5_out_1 = NULL; BandColormap_Inquire_2_out_1 = NULL; BandColormap_Compute_17_out_1 = NULL; BandColormap_Enumerate_2_out_1 = NULL; BandColormap_Select_3_out_1 = NULL; BandColormap_Compute_18_out_1 = NULL; BandColormap_Statistics_1_out_4 = NULL; BandColormap_Statistics_1_out_5 = NULL; BandColormap_Compute_22_out_1 = NULL; BandColormap_Transmitter_9_out_1 = NULL; BandColormap_Receiver_17_out_1 = NULL; BandColormap_Compute_20_out_1 = NULL; BandColormap_Transmitter_8_out_1 = NULL; BandColormap_Receiver_14_out_1 = NULL; BandColormap_Transmitter_11_out_1 = NULL; BandColormap_Receiver_19_out_1 = NULL; BandColormap_Map_6_out_1 = NULL; BandColormap_ArrayDouble_2_out_1 = NULL; BandColormap_Extract_6_out_1 = NULL; BandColormap_CollectNamed_1_out_1 = NULL; BandColormap_Input_7_out_1 = NULL; BandColormap_Transmitter_12_out_1 = NULL; BandColormap_Receiver_20_out_1 = NULL; BandColormap_Select_5_out_1 = NULL; BandColormap_Receiver_16_out_1 = NULL; BandColormap_Enumerate_3_out_1 = NULL; BandColormap_Select_4_out_1 = NULL; BandColormap_Construct_7_out_1 = NULL; BandColormap_Replace_1_out_1 = NULL;