/usr/share/nip2/compat/7.9/Statistics.def is in nip2 7.26.3-1build1.
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 | /* mean value of object
*/
Mean a = map_unary mean a;
/* standard deviation of object
*/
Deviation a = map_unary deviation a;
/* calculate a large set of stats on an object
*/
Stats a = map_unary stats a;
#separator
/* maximum of an object
*/
Max a = map_unary max a;
/* minimum of an object
*/
Min a = map_unary min a;
/* return complex number (max, min)
*/
Maxmin a
= map_unary maxmin a
{
maxmin x = (Max x, Min x);
}
/* position of maximum in an image
*/
Maximum_position a = map_unary maxpos a;
/* position of minimum in an image
*/
Minimum_position a = map_unary minpos a;
#separator
/* count the number of non-zeros in an image
*/
Count_set a
= map_unary cset a
{
cset i = (mean (i != 0) * i.width * i.height) / 255;
}
/* count the number of zeros in an image
*/
Count_clear a
= map_unary cclear a
{
cclear i = (mean (i == 0) * i.width * i.height) / 255;
}
#separator
/* plot a scatter graph of a list of [x,y] coordinates
*/
Plot_scatter x
//= map_unary widget x
= widget x
{
widget data
= class
Image value {
_check_args = [
[data, "data", check_xy_list]
] ++ super._check_args;
width = 512;
height = 512;
plot_colour = Colour "Lab" [80, -80, 80];
xmin = foldr1 min_pair (map (extract 0) data);
xmax = foldr1 max_pair (map (extract 0) data);
ymin = foldr1 min_pair (map (extract 1) data);
ymax = foldr1 max_pair (map (extract 1) data);
axies = Toggle "Draw axies" true;
mark
= Point this x y
{
p = _to_image data?0;
x = p?0;
y = p?1;
}
mark_position_hint = "mark is at position:";
mark_position = _from_image [mark.left, mark.top];
// geometry
_xrange = xmax - xmin;
_yrange = ymax - ymin;
_xscale = width / _xrange;
_yscale = height / _yrange;
// map an [x,y] point into the image coordinates
_to_image p = [(p?0 - xmin) * _xscale,
height - (p?1 - ymin) * _yscale];
// map an [x,y] point from image cods back to real cods
_from_image p = [p?0 / _xscale + xmin,
(height - p?1) / _yscale + ymin];
value
= foldr plot background' data
{
plot_image_new width height pixel
= image_new width height 3
Image_format.FLOAT
Image_coding.NOCODING
(Image_type.colour_spaces.lookup
0 1 plot_colour.colour_space)
pixel 0 0;
// background
background = plot_image_new width height 0;
// mark we plot
mark_width = max_pair 1 (width / 100);
mark_height = max_pair 1 (height / 100);
mark = plot_image_new mark_width mark_height
plot_colour;
// draw axies on background
background'
= drawxy, axies
= background
{
// axies
xaxis = plot_image_new width 1
(Colour "Lab" [100, 0, 0]);
yaxis = plot_image_new 1 height
(Colour "Lab" [100, 0, 0]);
origin = _to_image [0, 0];
drawx = im_insert_noexpand
background xaxis 0 origin?1;
drawxy = im_insert_noexpand
drawx yaxis origin?0 0;
}
// plot a single point on an image
plot p im
= im_insert_noexpand im mark
(x - mark_width / 2)
(y - mark_height / 2)
{
p' = _to_image p;
x = p'?0;
y = p'?1;
}
}
}
}
|