/usr/share/nip2/compat/7.14/Histogram.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 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 | Hist_new_item = class
Menupullright "_New" "new histogram" {
Hist_item = class
Menuaction "Histogram" "make an identity histogram" {
action = class
_result {
_vislevel = 3;
d = Option "Depth" ["8 bit", "16 bit"] 0;
_result = Plot [] ([im_identity 1, im_identity_ushort 1 65536]?d);
}
}
Hist_new_from_matrix = Matrix_buildlut_item;
Hist_from_image_item = class
Menuaction "Ta_g Image As Histogram" "set image Type field to Histogram" {
action x = hist_tag x;
}
Tone_item = class
Menuaction "_Tone Curve" "make a new tone mapping curve" {
action = class
_result {
_vislevel = 3;
d = Option "Depth" ["8 bit", "16 bit"] 0;
b = Scale "Black point" 0 100 0;
w = Scale "White point" 0 100 100;
sp = Scale "Shadow point" 0.1 0.3 0.2;
mp = Scale "Mid-tone point" 0.4 0.6 0.5;
hp = Scale "Highlight point" 0.7 0.9 0.8;
sa = Scale "Shadow adjust" (-15) 15 0;
ma = Scale "Mid-tone adjust" (-30) 30 0;
ha = Scale "Highlight adjust" (-15) 15 0;
_result
= tone_build fmt b w sp mp hp sa ma ha
{
fmt = [Image_format.UCHAR, Image_format.USHORT]?d;
}
}
}
}
Hist_find_item = class
Menupullright "_Find" "find a histogram" {
Oned_item = class
Menuaction "_One Dimension"
"for a n-band image, make an n-band 1D histogram" {
action x = map_unary hist_find x;
}
Nd_item = class
Menuaction "_Many Dimensions"
"for a n-band image, make an n-dimensional histogram" {
action x = class
_result {
_vislevel = 3;
// default to something small-ish
bins = Expression "Number of bins in each dimension" 8;
_result
= map_unary process x
{
process in
= hist_find_nD bins in;
}
}
}
}
Hist_map_item = class
Menuaction "_Map Histogram" "map an image through a histogram" {
action x y
= map_binary map x y
{
map a b
= hist_map hist im
{
[im, hist] = sortc (const is_hist) [a, b];
}
}
}
Hist_eq_item = Filter_enhance_item.Hist_equal_item;
#separator
Hist_cum_item = class
Menuaction "_Cumulativise Histogram"
"form cumulative histogram" {
action x = map_unary hist_cum x;
}
Hist_diff_item = class
Menuaction "_Differentiate Histogram"
"find point-to-point differences (inverse of Cumulativise)" {
action x = map_unary hist_diff x;
}
Hist_norm_item = class
Menuaction "N_ormalise Histogram" "normalise a histogram" {
action x = map_unary hist_norm x;
}
Hist_match_item = class
Menuaction "Ma_tch Histogram"
"find LUT which will match first histogram to second" {
action in ref = map_binary hist_match in ref;
}
Hist_zerox_item = class
Menuaction "_Zero Crossings" "find zero crossings" {
action x = class
_result {
_vislevel = 3;
edge = Option "Direction" [
"Positive-going",
"Negative-going"
] 0;
_result
= map_unary (zerox (if edge == 0 then -1 else 1)) x;
}
}
#separator
Hist_profile_item = class
Menuaction "Find _Profile"
"search from image edges for non-zero pixels" {
action x = class
_result {
_vislevel = 3;
edge = Option "Search from" [
"Top edge down",
"Left edge to right",
"Bottom edge up",
"Right edge to left"
] 2;
_result
= map_unary profile x
{
profile image
= (Plot_histogram @ hist_tag) [
profilemb 0 image.value,
profilemb 1 image.value,
profilemb 0 (fliptb image.value),
profilemb 1 (fliplr image.value)
]?edge;
// im_profile only does 1 band images :-(
profilemb d = bandjoin @ map (converse im_profile d) @ bandsplit;
}
}
}
Hist_project_item = class
Menuaction "Find Pro_jections"
"find horizontal and vertical projections" {
action x = class {
_vislevel = 2;
_result = map_unary project x;
// extract the result ... could be a group
extr n
= Plot_histogram _result?n, is_list _result
= Group (map (Plot_histogram @ converse subscript n) _result.value);
horizontal = extr 0;
vertical = extr 1;
centre = (gravity horizontal, gravity vertical);
}
}
#separator
Hist_graph_item = class
Menuaction "P_lot Slice" "plot a slice along a guide or arrow" {
action x = class
_value {
_vislevel = 3;
width = Scale "Width" 1 40 1;
displace = Scale "Horizontal displace" (-50) 50 0;
vdisplace = Scale "Vertical displace" (-50) 50 0;
_value
= map_unary graph x
{
graph arrow
= hist_tag area'
{
// the line as a polar vector
pv = polar (arrow.width, arrow.height);
a = im pv;
// smallest rotation that will make the line horizontal
a'
= 360 - a, a > 270
= 180 - a, a > 90
= -a;
im' = rotate a' arrow.image;
// look at the start and end of the arrow, pick the leftmost
p
= (arrow.left, arrow.top), arrow.left <= arrow.right
= (arrow.right, arrow.bottom);
// transform that point to im' space
p' = rectangular (polar p + (0, a')) +
(im'.xoffset, im'.yoffset);
// extract that area
area = extract_area
(re p' + displace.value)
(im p' - width.value / 2 + vdisplace.value)
(re pv) width.value
im';
// squish vertically to get an average
area' = resize 1 (1 / width.value) Interpolate.BILINEAR area;
}
}
}
}
Extract_arrow_item = class
Menuaction "Extract _Arrow" "extract the area around an arrow" {
action x = class
_value {
_vislevel = 3;
width = Scale "Width" 1 40 1;
displace = Scale "Horizontal displace" (-50) 50 0;
vdisplace = Scale "Vertical displace" (-50) 50 0;
_value
= map_unary graph x
{
graph arrow
= area
{
// the line as a polar vector
pv = polar (arrow.width, arrow.height);
a = im pv;
// smallest rotation that will make the line horizontal
a'
= 360 - a, a > 270
= 180 - a, a > 90
= -a;
im' = rotate a' arrow.image;
// look at the start and end of the arrow, pick the leftmost
p
= (arrow.left, arrow.top), arrow.left <= arrow.right
= (arrow.right, arrow.bottom);
// transform that point to im' space
p' = rectangular (polar p + (0, a')) +
(im'.xoffset, im'.yoffset);
// extract that area
area = extract_area
(re p' + displace.value)
(im p' - width.value / 2 + vdisplace.value)
(re pv) width.value
im';
}
}
}
}
Hist_plot_item = class
Menuaction "Plot _Object"
"plot an object as a bar, point or line graph" {
action x = class
_result {
_vislevel = 3;
format = Option_enum Plot_format.names "Format" "YYYY";
style = Option_enum Plot_style.names "Style" "Line";
auto = Toggle "Auto Range" true;
xmin = Expression "X range minimum" 0;
xmax = Expression "X range maximum" 1;
ymin = Expression "Y range minimum" 0;
ymax = Expression "Y range maximum" 1;
_result
= Plot options (image x)
{
options
= [$style => style.value, $format => format.value] ++ range;
range
= [], auto
= [$xmin => xmin.expr, $xmax => xmax.expr,
$ymin => ymin.expr, $ymax => ymax.expr];
image x
= image (extract_arrow x), is_Arrow x
= get_image x, has_image x
= x2b im, b == 1
= im
{
im = get_image (to_image x);
w = get_width im;
h = get_height im;
b = get_bands im;
// matrix to image makes a 1-band mxn image
// we need to put columns into bands
x2b im
= bandjoin (map extract_col [0 .. w - 1])
{
extract_col x = extract_area x 0 1 h im;
}
}
extract_arrow arrow
= extract_area (re p') (im p') (re pv) 1 im'
{
// the line as a polar vector
pv = polar (arrow.width, arrow.height);
a = im pv;
// smallest rotation that will make the line horizontal
a'
= 360 - a, a > 270
= 180 - a, a > 90
= -a;
im' = rotate a' arrow.image;
// look at the start and end of the arrow, pick the leftmost
p
= (arrow.left, arrow.top), arrow.left <= arrow.right
= (arrow.right, arrow.bottom);
// transform that point to im' space
p' = rectangular (polar p + (0, a')) +
(im'.xoffset, im'.yoffset);
}
}
}
}
|