This file is indexed.

/usr/share/nip2/compat/7.8/Mosaic.def is in nip2 7.28.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
/* Check and group a point list by image.
 */
_mosaic_sort_test l
	= error "mosaic: not all points",
		!is_listof (is_instanceof "Point") l
	= error "mosaic: points not on two images",
		len images != 2 
	= error "mosaic: images do not match in format and coding",
		!all_equal (map get_format l) ||
		!all_equal (map get_coding l)
	= error "mosaic: not same number of points on each image",
		!foldr1 equal (map len l') 
	= l'
{
	// test for all elements of a list equal
	all_equal l = land (map (equal (hd l)) (tl l));

	get_format x = x.image.format;
	get_coding x = x.image.coding;

	// all the different images
	get_image x = x.image;
	images = mkset pointer_equal (map get_image l);

	// find all points defined on image
	test_image image p = p.image === image;
	find l image = filter (test_image image) l;

	// group point list by image
	l' = map (find l) images;
}

/* Sort a point group to get right before left, and within each group to get 
 * above before below.
 */
_mosaic_sort_lr l
	= l''
{
	// sort to get upper point first
	above a b = a.top < b.top;
	l' = map (sortc above) l;

	// sort to get right group before left group
	right a b = (a?0).left > (b?0).left;
	l'' = sortc right l';
}

/* Sort a point group to get top before bottom, and within each group to get 
 * left before right.
 */
_mosaic_sort_tb l
	= l''
{
	// sort to get upper point first
	left a b = a.left < b.left;
	l' = map (sortc left) l;

	// sort to get right group before left group
	below a b = (a?0).top > (b?0).top;
	l'' = sortc below l';
}

/* Put 'em together! Group by image, sort vertically (or horizontally) with
 * one of the above, transpose to get pairs matched up, and flatten again.
 */
_mosaic_sort fn = concat @ transpose @ fn @ _mosaic_sort_test;

/* translate and blend two images together left/right or up/down
 */
Mosaic_translate = class {
	_check_ab_args a b = [
		[a, "a", check_Point],
		[b, "b", check_Point]
	];

	// shortcut to prefs
	_prefs = Workspaces.Preferences;
	_search_area = _prefs.MOSAIC_WINDOW_SIZE;
	_object_size = _prefs.MOSAIC_OBJECT_SIZE;
	_blend_width = Slider 0 100 _prefs.MOSAIC_MAX_BLEND_WIDTH;
	_refine = Toggle "Refine selected tie-points" _prefs.MOSAIC_REFINE;

	/* translate and blend two images left/right
	 */
	Left_right a b = class 
		Image value {
		_check_args = _check_ab_args a b ++ super._check_args;

		blend_width = _blend_width;
		refine = _refine;

		value 
			= im_lrmosaic a'.image.value b'.image.value
				0
				ra'.left ra'.top
				rb'.left rb'.top
				(_object_size / 2) (_search_area / 2)
				0
				blend_width.value,
					refine
			= im_lrmerge a'.image.value b'.image.value
				(rb'.left - ra'.left)
				(rb'.top - ra'.top)
				blend_width.value
		{
			sorted = _mosaic_sort _mosaic_sort_lr [a, b];
			a' = sorted?0;
			b' = sorted?1;
			ra' = a'.image_rect;
			rb' = b'.image_rect;
		}
	}

	/* translate and blend two images top/bottom
	 */
	Top_bottom a b = class 
		Image value {
		_check_args = _check_ab_args a b ++ super._check_args;

		blend_width = _blend_width;
		refine = _refine;

		value 
			= im_tbmosaic a'.image.value b'.image.value
				0
				ra'.left ra'.top
				rb'.left rb'.top
				(_object_size / 2) (_search_area / 2)
				0
				blend_width.value,
					refine
			= im_tbmerge a'.image.value b'.image.value
				(rb'.left - ra'.left)
				(rb'.top - ra'.top)
				blend_width.value
		{
			sorted = _mosaic_sort _mosaic_sort_tb [a, b];
			a' = sorted?0;
			b' = sorted?1;
			ra' = a'.image_rect;
			rb' = b'.image_rect;
		}
	}
}

/* forcibly translate and blend two images together left/right or up/down
 */
Mosaic_force = class {
	_check_ab_args a b = [
		[a, "a", check_Point],
		[b, "b", check_Point]
	];

	// shortcut to prefs
	_prefs = Workspaces.Preferences;
	_blend_width = Slider 0 100 _prefs.MOSAIC_MAX_BLEND_WIDTH;

	/* forcibly translate and blend two images left/right
	 */
	Left_right a b = class 
		Image value {
		_check_args = _check_ab_args a b ++ super._check_args;

		blend_width = _blend_width;

		value 
			= im_lrmerge a'.image.value b'.image.value
				(rb'.left - ra'.left)
				(rb'.top - ra'.top)
				blend_width.value
		{
			sorted = _mosaic_sort _mosaic_sort_lr [a, b];
			a' = sorted?0;
			b' = sorted?1;
			ra' = a'.image_rect;
			rb' = b'.image_rect;
		}
	}

	/* forcibly translate and blend two images top/bottom
	 */
	Top_bottom a b = class 
		Image value {
		_check_args = _check_ab_args a b ++ super._check_args;

		blend_width = _blend_width;

		value 
			= im_tbmerge a'.image.value b'.image.value
				(rb'.left - ra'.left)
				(rb'.top - ra'.top)
				blend_width.value
		{
			sorted = _mosaic_sort _mosaic_sort_tb [a, b];
			a' = sorted?0;
			b' = sorted?1;
			ra' = a'.image_rect;
			rb' = b'.image_rect;
		}
	}
}

/* translate, rotate, scale and blend two images together left/right or up/down
 */
Mosaic_affine = class {
	_check_abcd_args a b c d = [
		[a, "a", check_Point],
		[b, "b", check_Point],
		[c, "c", check_Point],
		[d, "d", check_Point]
	];

	// shortcut to prefs
	_prefs = Workspaces.Preferences;
	_search_area = _prefs.MOSAIC_WINDOW_SIZE;
	_object_size = _prefs.MOSAIC_OBJECT_SIZE;
	_blend_width = Slider 0 100 _prefs.MOSAIC_MAX_BLEND_WIDTH;
	_refine = Toggle "Refine selected tie-points" _prefs.MOSAIC_REFINE;

	/* translate, rotate, scale and blend two images left/right
	 */
	Left_right a b c d = class 
		Image value {
		_check_args = _check_abcd_args a b c d ++ super._check_args;

		blend_width = _blend_width;
		refine = _refine;

		value 
			= im_lrmosaic1 a'.image.value b'.image.value
				0
				ra'.left ra'.top
				rb'.left rb'.top
				rc'.left rc'.top
				rd'.left rd'.top
				(_object_size / 2) (_search_area / 2)
				0
				blend_width.value,
					refine
			= im_lrmerge1 a'.image.value b'.image.value
				ra'.left ra'.top
				rb'.left rb'.top
				rc'.left rc'.top
				rd'.left rd'.top
				blend_width.value
		{
			sorted = _mosaic_sort _mosaic_sort_lr [a, b, c, d];
			a' = sorted?0;
			b' = sorted?1;
			c' = sorted?2;
			d' = sorted?3;
			ra' = a'.image_rect;
			rb' = b'.image_rect;
			rc' = c'.image_rect;
			rd' = d'.image_rect;
		}
	}

	/* translate, rotate, scale and blend two images top/bottom
	 */
	Top_bottom a b c d = class 
		Image value {
		_check_args = _check_abcd_args a b c d ++ super._check_args;

		blend_width = _blend_width;
		refine = _refine;

		value 
			= im_tbmosaic1 a'.image.value b'.image.value
				0
				ra'.left ra'.top
				rb'.left rb'.top
				rc'.left rc'.top
				rd'.left rd'.top
				(_object_size / 2) (_search_area / 2)
				0
				blend_width.value,
					refine
			= im_tbmerge1 a'.image.value b'.image.value
				ra'.left ra'.top
				rb'.left rb'.top
				rc'.left rc'.top
				rd'.left rd'.top
				blend_width.value
		{
			sorted = _mosaic_sort _mosaic_sort_tb [a, b, c, d];
			a' = sorted?0;
			b' = sorted?1;
			c' = sorted?2;
			d' = sorted?3;
			ra' = a'.image_rect;
			rb' = b'.image_rect;
			rc' = c'.image_rect;
			rd' = d'.image_rect;
		}
	}
}

#separator

/* disassemble mosaic, adjust brightnesses to match, and reassemble
 */
Mosaic_balance x
	= map_unary balance x
{
	balance x
		= oo_unary_function balance_op x, is_class x
		= im_global_balancef x 
			Workspaces.Preferences.MOSAIC_BALANCE_GAMMA, 
			is_image x
		= error (errors.badargs ++ "balance")
	{
		balance_op = Operator "balance" balance 
			Operator_type.COMPOUND_REWRAP false;
	}
}

/* brighten along a left/right or up/down axis
 */
Tilt_brightness = class {
	/* brighten along a left/right axis
	 */
	Left_right x 
		= map_unary tilt_lr x
	{
		tilt_lr image = class
			Image value {
			_check_args = [
				[image, "image", check_Image]
			] ++ super._check_args;
			_vislevel = 3;

			tilt = Slider (-1) 1 0;

			value
				= final
			{
				ramp = im_fgrey image.width image.height;
				ramp' = bandjoin 
					(map (const ramp) [1..image.bands]);
				scale = (ramp' - 0.5) * tilt + 1;
				final = image.value * scale;
			}
		}
	}

	/* brighten along a top/bottom axis
	 */
	Top_bottom x 
		= map_unary tilt_tb x
	{
		tilt_tb image = class
			Image value {
			_check_args = [
				[image, "image", check_Image]
			] ++ super._check_args;
			_vislevel = 3;

			tilt = Slider (-1) 1 0;

			value
				= final
			{
				ramp = rot90 
					(im_fgrey image.height image.width);
				ramp' = bandjoin 
					(map (const ramp) [1..image.bands]);
				scale = (ramp' - 0.5) * tilt + 1;
				final = image.value * scale;
			}
		}
	}
}

#separator

/* disassemble mosaic, substitute different image files, and reassemble
 */
Mosaic_rebuild x 
	= map_unary remosaic x
{
	remosaic image = class
		Image value {
		_check_args = [
			[image, "image", check_Image]
		] ++ super._check_args;
		_vislevel = 3;

		old_hint = "For the name of each file making up the mosaic, " ++
			"exchange this string:";
		old = "foo";
		new_hint = "for this string:";
		new = "bar";

		value = im_remosaic image.value old new;
	}
}