// // time: Tue Apr 22 08:56:14 1997 // // version: 3.1.1 (format), 3.1.4 (DX Beta) // // // MODULE main // // comment: This visual program shows some uses of the Overlay module. In two cases, an image is imported, and a new caption is added. For generality, the original image is queried using Inquire to determine its x and y resolution (note that for images imported using Readimage, the first component of the position counts is the number of y pixels, and the second component is the number of x pixels). The resolution and aspect ratio of the original image is used to create a camera for the new caption. // comment: // comment: If the blend parameter to Overlay is 0.5 (the default), then each image is multiplied by 0.5 and they are added together. This results in a rather dim image. If, however, the blend parameter is set to black, then the original image is used everywhere except where it is black. Where it is black, the caption image is used instead. // comment: // comment: An example is also shown of setting every black pixel in the original image to red. This is done by chromakeying an entirely red image with the original image using blend=black. For comparison, the same operation can be performed using Compute. // comment: // comment: Finally an example using a mask for the blend parameter is shown. The mask has a cosine function in the x direction. In this case the blend parameter varies from 1 near the right and left edges (resulting in only the red image) to 0 near the center (resulting in only the original image). // page assignment: blend order=4, windowed=0, showing=0 // page assignment: blend_black order=5, windowed=0, showing=0 // page assignment: blend_mask order=8, windowed=0, showing=0 // page assignment: blend_red order=6, windowed=0, showing=0 // page assignment: caption_imag order=3, windowed=0, showing=0 // page assignment: compute_red order=7, windowed=0, showing=0 // page assignment: display order=9, windowed=0, showing=0 // page assignment: import_image order=2, windowed=0, showing=1 // workspace: width = 587, height = 461 // layout: snap = 0, width = 50, height = 50, align = UL // macro main( ) -> ( ) { // // node Caption[1]: x = 20, y = 41, inputs = 9, label = Caption // input[1]: defaulting = 0, visible = 1, type = 32, value = "New Title" // input[6]: defaulting = 0, visible = 1, type = 1, value = 25 // input[7]: defaulting = 0, visible = 1, type = 32, value = "roman_tser" // page group: caption_imag // main_Caption_1_out_1 = Caption( main_Caption_1_in_1, main_Caption_1_in_2, main_Caption_1_in_3, main_Caption_1_in_4, main_Caption_1_in_5, main_Caption_1_in_6, main_Caption_1_in_7, main_Caption_1_in_8, main_Caption_1_in_9 ) [instance: 1, cache: 1]; // // node ReadImage[1]: x = 112, y = 60, inputs = 9, label = ReadImage // input[1]: defaulting = 0, visible = 1, type = 32, value = "cylinder.rgb" // input[9]: defaulting = 0, visible = 1, type = 32, value = "float" // page group: import_image // main_ReadImage_1_out_1 = ReadImage( main_ReadImage_1_in_1, main_ReadImage_1_in_2, main_ReadImage_1_in_3, main_ReadImage_1_in_4, main_ReadImage_1_in_5, main_ReadImage_1_in_6, main_ReadImage_1_in_7, main_ReadImage_1_in_8, main_ReadImage_1_in_9 ) [instance: 1, cache: 1]; // // node Inquire[1]: x = 26, y = 125, inputs = 3, label = Inquire // input[2]: defaulting = 0, visible = 1, type = 32, value = "position gridcounts" // page group: import_image // main_Inquire_1_out_1 = Inquire( main_ReadImage_1_out_1, main_Inquire_1_in_2, main_Inquire_1_in_3 ) [instance: 1, cache: 1]; // // node Compute[2]: x = 0, y = 222, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "$0.1" // page group: import_image // expression: value = imagesize.1 // name[2]: value = imagesize // main_Compute_2_out_1 = Compute( main_Compute_2_in_1, main_Inquire_1_out_1 ) [instance: 2, cache: 1]; // // node Transmitter[2]: x = 17, y = 396, inputs = 1, label = x_res // page group: import_image // x_res = main_Compute_2_out_1; // // node Receiver[9]: x = 224, y = 30, inputs = 1, label = x_res // page group: caption_imag // main_Receiver_9_out_1[cache: 0] = x_res; // // node Compute[1]: x = 86, y = 211, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "$0.0" // page group: import_image // expression: value = imagesize.0 // name[2]: value = imagesize // main_Compute_1_out_1 = Compute( main_Compute_1_in_1, main_Inquire_1_out_1 ) [instance: 1, cache: 1]; // // node Transmitter[3]: x = 113, y = 399, inputs = 1, label = y_res // page group: import_image // y_res = main_Compute_1_out_1; // // node Receiver[8]: x = 294, y = 30, inputs = 1, label = y_res // page group: caption_imag // main_Receiver_8_out_1[cache: 0] = y_res; // // node Compute[3]: x = 204, y = 148, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "float($1)/float($0)" // page group: caption_imag // expression: value = float(imagey)/float(imagex) // name[2]: value = imagex // name[3]: value = imagey // main_Compute_3_out_1 = Compute( main_Compute_3_in_1, main_Receiver_9_out_1, main_Receiver_8_out_1 ) [instance: 3, cache: 1]; // // node AutoCamera[1]: x = 122, y = 228, inputs = 9, label = AutoCamera // input[4]: visible = 1 // input[5]: visible = 1 // page group: caption_imag // main_AutoCamera_1_out_1 = AutoCamera( main_Caption_1_out_1, main_AutoCamera_1_in_2, main_AutoCamera_1_in_3, main_Receiver_9_out_1, main_Compute_3_out_1, main_AutoCamera_1_in_6, main_AutoCamera_1_in_7, main_AutoCamera_1_in_8, main_AutoCamera_1_in_9 ) [instance: 1, cache: 1]; // // node Render[1]: x = 74, y = 346, inputs = 3, label = Render // page group: caption_imag // main_Render_1_out_1 = Render( main_Caption_1_out_1, main_AutoCamera_1_out_1, main_Render_1_in_3 ) [instance: 1, cache: 1]; // // node Transmitter[4]: x = 66, y = 463, inputs = 1, label = caption_image // page group: caption_imag // caption_image = main_Render_1_out_1; // // node Receiver[12]: x = 20, y = 20, inputs = 1, label = caption_image // page group: blend_red // main_Receiver_12_out_1[cache: 0] = caption_image; // // node Color[1]: x = 54, y = 207, inputs = 5, label = Color // input[2]: defaulting = 0, visible = 1, type = 32, value = "red" // page group: blend_red // main_Color_1_out_1 = Color( main_Receiver_12_out_1, main_Color_1_in_2, main_Color_1_in_3, main_Color_1_in_4, main_Color_1_in_5 ) [instance: 1, cache: 1]; // // node Receiver[14]: x = 186, y = 36, inputs = 1, label = caption_image // page group: blend_mask // main_Receiver_14_out_1[cache: 0] = caption_image; // // node Mark[1]: x = 205, y = 238, inputs = 2, label = Mark // input[2]: defaulting = 0, visible = 1, type = 32, value = "positions" // page group: blend_mask // main_Mark_1_out_1 = Mark( main_Receiver_14_out_1, main_Mark_1_in_2 ) [instance: 1, cache: 1]; // // node Receiver[2]: x = 309, y = 31, inputs = 1, label = x_res // page group: blend_mask // main_Receiver_2_out_1[cache: 0] = x_res; // // node Compute[4]: x = 210, y = 378, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "abs(cos((3.14/$1)*$0.x))" // page group: blend_mask // expression: value = abs(cos((3.14/xres)*image.x)) // name[2]: value = image // name[3]: value = xres // main_Compute_4_out_1 = Compute( main_Compute_4_in_1, main_Mark_1_out_1, main_Receiver_2_out_1 ) [instance: 4, cache: 1]; // // node Transmitter[1]: x = 178, y = 399, inputs = 1, label = orig_image // page group: import_image // orig_image = main_ReadImage_1_out_1; // // node Receiver[7]: x = 53, y = 32, inputs = 1, label = orig_image // page group: compute_red // main_Receiver_7_out_1[cache: 0] = orig_image; // // node Mark[2]: x = 75, y = 144, inputs = 2, label = Mark // input[2]: defaulting = 0, visible = 1, type = 32, value = "colors" // page group: compute_red // main_Mark_2_out_1 = Mark( main_Receiver_7_out_1, main_Mark_2_in_2 ) [instance: 2, cache: 1]; // // node Compute[15]: x = 69, y = 237, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "mag($0)==0.0 ? [1.0, 0.0, 0.0] : $0" // page group: compute_red // expression: value = mag(a)==0.0 ? [1.0, 0.0, 0.0] : a // name[2]: value = a // main_Compute_15_out_1 = Compute( main_Compute_15_in_1, main_Mark_2_out_1 ) [instance: 15, cache: 1]; // // node Selector[1]: x = 15, y = 257, inputs = 7, label = Selector // input[1]: defaulting = 0, visible = 0, type = 32, value = "Selector_1" // input[2]: defaulting = 0, visible = 0, type = 32, value = "blending two images, using blend = black" // input[3]: defaulting = 0, visible = 0, type = 29, value = 2 // input[4]: defaulting = 1, visible = 1, type = 16777248, value = { "blending two images, blend = .5" "blending two images, using blend = black" "setting black to red using Overlay" "setting black to red using Compute" "blending image with red using mask" } // input[5]: defaulting = 1, visible = 0, type = 16777245, value = { 1 2 3 4 5 } // output[1]: visible = 1, type = 29, value = 2 // output[2]: visible = 1, type = 32, value = "blending two images, using blend = black" // page group: display // // // node Receiver[11]: x = 20, y = 22, inputs = 1, label = caption_image // page group: blend // main_Receiver_11_out_1[cache: 0] = caption_image; // // node Receiver[10]: x = 143, y = 20, inputs = 1, label = orig_image // page group: blend // main_Receiver_10_out_1[cache: 0] = orig_image; // // node Overlay[1]: x = 92, y = 219, inputs = 3, label = Overlay // input[3]: defaulting = 0, visible = 1, type = 5, value = .5 // page group: blend // main_Overlay_1_out_1 = Overlay( main_Receiver_11_out_1, main_Receiver_10_out_1, main_Overlay_1_in_3 ) [instance: 1, cache: 1]; // // node Transmitter[5]: x = 105, y = 372, inputs = 1, label = blend // page group: blend // blend = main_Overlay_1_out_1; // // node Receiver[15]: x = 43, y = 91, inputs = 1, label = blend // page group: display // main_Receiver_15_out_1[cache: 0] = blend; // // node Receiver[16]: x = 21, y = 89, inputs = 1, label = caption_image // page group: blend_black // main_Receiver_16_out_1[cache: 0] = caption_image; // // node Receiver[13]: x = 142, y = 90, inputs = 1, label = orig_image // page group: blend_black // main_Receiver_13_out_1[cache: 0] = orig_image; // // node Overlay[2]: x = 41, y = 321, inputs = 3, label = Overlay // input[3]: defaulting = 0, visible = 1, type = 32, value = "black" // page group: blend_black // main_Overlay_2_out_1 = Overlay( main_Receiver_16_out_1, main_Receiver_13_out_1, main_Overlay_2_in_3 ) [instance: 2, cache: 1]; // // node Transmitter[6]: x = 34, y = 454, inputs = 1, label = blend_black // page group: blend_black // blend_black = main_Overlay_2_out_1; // // node Receiver[17]: x = 93, y = 91, inputs = 1, label = blend_black // page group: display // main_Receiver_17_out_1[cache: 0] = blend_black; // // node Receiver[1]: x = 192, y = 26, inputs = 1, label = orig_image // page group: blend_red // main_Receiver_1_out_1[cache: 0] = orig_image; // // node Overlay[3]: x = 81, y = 329, inputs = 3, label = Overlay // input[3]: defaulting = 0, visible = 1, type = 32, value = "black" // page group: blend_red // main_Overlay_3_out_1 = Overlay( main_Color_1_out_1, main_Receiver_1_out_1, main_Overlay_3_in_3 ) [instance: 3, cache: 1]; // // node Transmitter[8]: x = 61, y = 468, inputs = 1, label = blend_red // page group: blend_red // blend_red = main_Overlay_3_out_1; // // node Receiver[20]: x = 244, y = 101, inputs = 1, label = blend_red // page group: display // main_Receiver_20_out_1[cache: 0] = blend_red; // // node Unmark[1]: x = 80, y = 337, inputs = 2, label = Unmark // input[2]: defaulting = 0, visible = 1, type = 32, value = "colors" // page group: compute_red // main_Unmark_1_out_1 = Unmark( main_Compute_15_out_1, main_Unmark_1_in_2 ) [instance: 1, cache: 1]; // // node Transmitter[9]: x = 76, y = 493, inputs = 1, label = compute_red // page group: compute_red // compute_red = main_Unmark_1_out_1; // // node Receiver[21]: x = 325, y = 93, inputs = 1, label = compute_red // page group: display // main_Receiver_21_out_1[cache: 0] = compute_red; // // node Transmitter[7]: x = 153, y = 472, inputs = 1, label = red_image // page group: blend_red // red_image = main_Color_1_out_1; // // node Receiver[19]: x = 10, y = 35, inputs = 1, label = red_image // page group: blend_mask // main_Receiver_19_out_1[cache: 0] = red_image; // // node Receiver[18]: x = 86, y = 33, inputs = 1, label = orig_image // page group: blend_mask // main_Receiver_18_out_1[cache: 0] = orig_image; // // node Overlay[4]: x = 123, y = 456, inputs = 3, label = Overlay // page group: blend_mask // main_Overlay_4_out_1 = Overlay( main_Receiver_19_out_1, main_Receiver_18_out_1, main_Compute_4_out_1 ) [instance: 4, cache: 1]; // // node Transmitter[10]: x = 133, y = 554, inputs = 1, label = mask // page group: blend_mask // mask = main_Overlay_4_out_1; // // node Receiver[22]: x = 435, y = 89, inputs = 1, label = mask // page group: display // main_Receiver_22_out_1[cache: 0] = mask; // // node Switch[1]: x = 184, y = 327, inputs = 6, label = Switch // page group: display // main_Switch_1_out_1 = Switch( main_Selector_1_out_1, main_Receiver_15_out_1, main_Receiver_17_out_1, main_Receiver_20_out_1, main_Receiver_21_out_1, main_Receiver_22_out_1 ) [instance: 1, cache: 1]; // // node Display[3]: x = 243, y = 487, inputs = 4, label = Display // page group: display // depth: value = 24 // window: position = (0.5039,0.1396), size = 0.2844x0.3613 // main_Display_3_out_1[cache: 2] = Display( main_Switch_1_out_1, main_Display_3_in_2, main_Display_3_in_3, main_Display_3_in_4 ) [instance: 3, cache: 1]; // // decorator Annotate pos=(37,25) size=550x28 style(Label), value = // annotation user_begin: 78 // annotation user: This page imports and image, and extracts the x and y resolution of the image. // annotation user_end: // page group: import_image // // decorator Annotate pos=(171,334) size=469x44 style(Label), value = // annotation user_begin: 113 // annotation user: This page creates a simple image, of the same size as the imported // annotation user: image, showing just a caption with "New Title" // annotation user_end: // page group: caption_imag // // decorator Annotate pos=(29,479) size=509x44 style(Label), value = // annotation user_begin: 93 // annotation user: This page simply blends the caption image with the original image using // annotation user: a blend factor of .5. // annotation user_end: // page group: blend // // decorator Annotate pos=(109,247) size=525x60 style(Label), value = // annotation user_begin: 167 // annotation user: This page blends the caption image with the original image using a // annotation user: blend value of "black", which allows the caption to replace the black pixels // annotation user: in the original image. // annotation user_end: // page group: blend_black // // decorator Annotate pos=(262,158) size=373x92 style(Label), value = // annotation user_begin: 274 // annotation user: This page colors the caption image red (creating a // annotation user: plain red image), then blends with the original image // annotation user: setting the blend factor to "black". This forces every // annotation user: black pixel in the original image to be turned to the // annotation user: color of the overlay image, which is of course, red. // annotation user_end: // page group: blend_red // // decorator Annotate pos=(144,93) size=474x44 style(Label), value = // annotation user_begin: 113 // annotation user: This page simply uses a conditional expression in Compute to turn // annotation user: every black pixel in the original image to red. // annotation user_end: // page group: compute_red // // decorator Annotate pos=(286,266) size=317x76 style(Label), value = // annotation user_begin: 188 // annotation user: This page creates a "mask field" using // annotation user: Compute, which is passed as the blend // annotation user: parameter to Overlay. This causes the blend // annotation user: factor used to vary across the image. // annotation user_end: // page group: blend_mask // // decorator Annotate pos=(30,40) size=511x28 style(Label), value = // annotation user_begin: 71 // annotation user: in this page the user chooses which use of Overlay (or Compute) to see. // annotation user_end: // page group: display // network: end of macro body } main_Caption_1_in_1 = "New Title"; main_Caption_1_in_2 = NULL; main_Caption_1_in_3 = NULL; main_Caption_1_in_4 = NULL; main_Caption_1_in_5 = NULL; main_Caption_1_in_6 = 25; main_Caption_1_in_7 = "roman_tser"; main_Caption_1_in_8 = NULL; main_Caption_1_in_9 = NULL; main_Caption_1_out_1 = NULL; main_ReadImage_1_in_1 = "cylinder.rgb"; main_ReadImage_1_in_2 = NULL; main_ReadImage_1_in_3 = NULL; main_ReadImage_1_in_4 = NULL; main_ReadImage_1_in_5 = NULL; main_ReadImage_1_in_6 = NULL; main_ReadImage_1_in_7 = NULL; main_ReadImage_1_in_8 = NULL; main_ReadImage_1_in_9 = "float"; main_ReadImage_1_out_1 = NULL; main_Inquire_1_in_2 = "position gridcounts"; main_Inquire_1_in_3 = NULL; main_Inquire_1_out_1 = NULL; main_Compute_2_in_1 = "$0.1"; main_Compute_2_out_1 = NULL; main_Transmitter_2_out_1 = NULL; main_Receiver_9_out_1 = NULL; main_Compute_1_in_1 = "$0.0"; main_Compute_1_out_1 = NULL; main_Transmitter_3_out_1 = NULL; main_Receiver_8_out_1 = NULL; main_Compute_3_in_1 = "float($1)/float($0)"; main_Compute_3_out_1 = NULL; main_AutoCamera_1_in_2 = NULL; main_AutoCamera_1_in_3 = NULL; main_AutoCamera_1_in_6 = NULL; main_AutoCamera_1_in_7 = NULL; main_AutoCamera_1_in_8 = NULL; main_AutoCamera_1_in_9 = NULL; main_AutoCamera_1_out_1 = NULL; main_Render_1_in_3 = NULL; main_Render_1_out_1 = NULL; main_Transmitter_4_out_1 = NULL; main_Receiver_12_out_1 = NULL; main_Color_1_in_2 = "red"; main_Color_1_in_3 = NULL; main_Color_1_in_4 = NULL; main_Color_1_in_5 = NULL; main_Color_1_out_1 = NULL; main_Receiver_14_out_1 = NULL; main_Mark_1_in_2 = "positions"; main_Mark_1_out_1 = NULL; main_Receiver_2_out_1 = NULL; main_Compute_4_in_1 = "abs(cos((3.14/$1)*$0.x))"; main_Compute_4_out_1 = NULL; main_Transmitter_1_out_1 = NULL; main_Receiver_7_out_1 = NULL; main_Mark_2_in_2 = "colors"; main_Mark_2_out_1 = NULL; main_Compute_15_in_1 = "mag($0)==0.0 ? [1.0, 0.0, 0.0] : $0"; main_Compute_15_out_1 = NULL; main_Selector_1_in_1 = "Selector_1"; main_Selector_1_in_2 = "blending two images, using blend = black" ; main_Selector_1_in_3 = 2 ; main_Selector_1_in_4 = NULL; main_Selector_1_in_5 = NULL; main_Selector_1_in_6 = NULL; main_Selector_1_in_7 = NULL; main_Selector_1_out_1 = 2 ; main_Receiver_11_out_1 = NULL; main_Receiver_10_out_1 = NULL; main_Overlay_1_in_3 = .5; main_Overlay_1_out_1 = NULL; main_Transmitter_5_out_1 = NULL; main_Receiver_15_out_1 = NULL; main_Receiver_16_out_1 = NULL; main_Receiver_13_out_1 = NULL; main_Overlay_2_in_3 = "black"; main_Overlay_2_out_1 = NULL; main_Transmitter_6_out_1 = NULL; main_Receiver_17_out_1 = NULL; main_Receiver_1_out_1 = NULL; main_Overlay_3_in_3 = "black"; main_Overlay_3_out_1 = NULL; main_Transmitter_8_out_1 = NULL; main_Receiver_20_out_1 = NULL; main_Unmark_1_in_2 = "colors"; main_Unmark_1_out_1 = NULL; main_Transmitter_9_out_1 = NULL; main_Receiver_21_out_1 = NULL; main_Transmitter_7_out_1 = NULL; main_Receiver_19_out_1 = NULL; main_Receiver_18_out_1 = NULL; main_Overlay_4_out_1 = NULL; main_Transmitter_10_out_1 = NULL; main_Receiver_22_out_1 = NULL; main_Switch_1_out_1 = NULL; main_Display_3_in_2 = NULL; main_Display_3_in_3 = "X24,,"; main_Display_3_in_4 = NULL; Executive("product version 3 1 4"); $sync main();