Skip to content

Commit 1473c1d

Browse files
committed
add 8.5 compat, update for combine modes
see hist_find_indexed
1 parent ea88d7f commit 1473c1d

24 files changed

+18901
-2
lines changed

share/nip2/compat/8.5/Colour.def

Lines changed: 680 additions & 0 deletions
Large diffs are not rendered by default.

share/nip2/compat/8.5/Filter.def

Lines changed: 1694 additions & 0 deletions
Large diffs are not rendered by default.

share/nip2/compat/8.5/Histogram.def

Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
Hist_new_item = class
2+
Menupullright "_New" "new histogram" {
3+
Hist_item = class
4+
Menuaction "_Identity" "make an identity histogram" {
5+
action = class
6+
_result {
7+
_vislevel = 3;
8+
9+
d = Option "Depth" ["8 bit", "16 bit"] 0;
10+
_result = Plot [] ([im_identity 1, im_identity_ushort 1 65536]?d);
11+
}
12+
}
13+
14+
Hist_new_from_matrix = Matrix_buildlut_item;
15+
16+
Hist_from_image_item = class
17+
Menuaction "Ta_g Image As Histogram" "set image Type to Histogram" {
18+
action x = hist_tag x;
19+
}
20+
21+
Tone_item = class
22+
Menuaction "_Tone Curve" "make a new tone mapping curve" {
23+
action = class
24+
_result {
25+
_vislevel = 3;
26+
27+
d = Option "Depth" ["8 bit", "16 bit"] 0;
28+
b = Scale "Black point" 0 100 0;
29+
w = Scale "White point" 0 100 100;
30+
31+
sp = Scale "Shadow point" 0.1 0.3 0.2;
32+
mp = Scale "Mid-tone point" 0.4 0.6 0.5;
33+
hp = Scale "Highlight point" 0.7 0.9 0.8;
34+
35+
sa = Scale "Shadow adjust" (-15) 15 0;
36+
ma = Scale "Mid-tone adjust" (-30) 30 0;
37+
ha = Scale "Highlight adjust" (-15) 15 0;
38+
39+
_result
40+
= tone_build fmt b w sp mp hp sa ma ha
41+
{
42+
fmt = [Image_format.UCHAR, Image_format.USHORT]?d;
43+
}
44+
}
45+
}
46+
}
47+
48+
Hist_convert_to_hist_item = class
49+
Menuaction "Con_vert to Histogram" "convert anything to a histogram" {
50+
action x = hist_tag (to_image x);
51+
}
52+
53+
Hist_find_item = class
54+
Menupullright "_Find" "find a histogram" {
55+
Oned_item = class
56+
Menuaction "_One Dimension"
57+
"for a n-band image, make an n-band 1D histogram" {
58+
action x = map_unary hist_find x;
59+
}
60+
61+
Nd_item = class
62+
Menuaction "_Many Dimensions"
63+
"for a n-band image, make an n-dimensional histogram" {
64+
action x = class
65+
_result {
66+
_vislevel = 3;
67+
68+
// default to something small-ish
69+
bins = Expression "Number of bins in each dimension" 8;
70+
71+
_result
72+
= map_unary process x
73+
{
74+
process in
75+
= hist_find_nD bins in;
76+
}
77+
}
78+
}
79+
80+
Indexed_item = class
81+
Menuaction "_Indexed"
82+
"use a 1-band index image to pick bins for an n-band image" {
83+
action x y
84+
= map_binary map x y
85+
{
86+
map a b
87+
= hist_find_indexed index im
88+
{
89+
[im, index] = sortc (const is_index) [a, b];
90+
91+
is_index x
92+
= has_image x && b == 1 &&
93+
(f == Image_format.UCHAR || f == Image_format.USHORT)
94+
{
95+
im = get_image x;
96+
b = get_bands x;
97+
f = get_format x;
98+
}
99+
}
100+
}
101+
}
102+
}
103+
104+
Hist_map_item = class
105+
Menuaction "_Map" "map an image through a histogram" {
106+
action x y
107+
= map_binary map x y
108+
{
109+
map a b
110+
= hist_map hist im
111+
{
112+
[im, hist] = sortc (const is_hist) [a, b];
113+
}
114+
}
115+
}
116+
117+
Hist_eq_item = Filter_enhance_item.Hist_equal_item;
118+
119+
#separator
120+
121+
Hist_cum_item = class
122+
Menuaction "_Integrate"
123+
"form cumulative histogram" {
124+
action x = map_unary hist_cum x;
125+
}
126+
127+
Hist_diff_item = class
128+
Menuaction "_Differentiate"
129+
"find point-to-point differences (inverse of Integrate)" {
130+
action x = map_unary hist_diff x;
131+
}
132+
133+
Hist_norm_item = class
134+
Menuaction "N_ormalise" "normalise a histogram" {
135+
action x = map_unary hist_norm x;
136+
}
137+
138+
Hist_inv_item = class
139+
Menuaction "In_vert" "invert a histogram" {
140+
action x = map_unary hist_inv x;
141+
}
142+
143+
Hist_match_item = class
144+
Menuaction "Ma_tch"
145+
"find LUT which will match first histogram to second" {
146+
action in ref = map_binary hist_match in ref;
147+
}
148+
149+
Hist_zerox_item = class
150+
Menuaction "_Zero Crossings" "find zero crossings" {
151+
action x = class
152+
_result {
153+
_vislevel = 3;
154+
155+
edge = Option "Direction" [
156+
"Positive-going",
157+
"Negative-going"
158+
] 0;
159+
160+
_result
161+
= map_unary (zerox (if edge == 0 then -1 else 1)) x;
162+
}
163+
}
164+
165+
Hist_entropy_item = class Menuaction "Entropy" "calculate histogram entropy" {
166+
action x = hist_entropy x;
167+
}
168+
169+
#separator
170+
171+
Hist_profile_item = class
172+
Menuaction "Find _Profile"
173+
"search from image edges for non-zero pixels" {
174+
action x = class
175+
_result {
176+
_vislevel = 3;
177+
178+
edge = Option "Search from" [
179+
"Top edge down",
180+
"Left edge to right",
181+
"Bottom edge up",
182+
"Right edge to left"
183+
] 2;
184+
185+
_result
186+
= map_unary profile x
187+
{
188+
profile image
189+
= (Plot_histogram @ hist_tag) [
190+
profilemb 0 image.value,
191+
profilemb 1 image.value,
192+
profilemb 0 (fliptb image.value),
193+
profilemb 1 (fliplr image.value)
194+
]?edge;
195+
196+
// im_profile only does 1 band images :-(
197+
profilemb d = bandjoin @ map (converse im_profile d) @ bandsplit;
198+
}
199+
}
200+
}
201+
202+
Hist_project_item = class
203+
Menuaction "Find Pro_jections"
204+
"find horizontal and vertical projections" {
205+
action x = class {
206+
_vislevel = 2;
207+
208+
_result = map_unary project x;
209+
210+
// extract the result ... could be a group
211+
extr n
212+
= Plot_histogram _result?n, is_list _result
213+
= Group (map (Plot_histogram @ converse subscript n) _result.value);
214+
215+
horizontal = extr 0;
216+
vertical = extr 1;
217+
centre = (gravity horizontal, gravity vertical);
218+
}
219+
}
220+
221+
#separator
222+
223+
Hist_graph_item = class
224+
Menuaction "P_lot Slice" "plot a slice along a guide or arrow" {
225+
action x = class
226+
_value {
227+
_vislevel = 3;
228+
229+
width = Scale "Width" 1 40 1;
230+
displace = Scale "Horizontal displace" (-50) 50 0;
231+
vdisplace = Scale "Vertical displace" (-50) 50 0;
232+
233+
_value
234+
= map_unary graph x
235+
{
236+
graph arrow
237+
= hist_tag area'
238+
{
239+
area = extract_arrow
240+
displace.value vdisplace.value width.value arrow;
241+
242+
// squish vertically to get an average
243+
area' = resize Kernel_linear 1 (1 / width.value) area;
244+
}
245+
}
246+
}
247+
}
248+
249+
Extract_arrow_item = class
250+
Menuaction "Extract _Arrow" "extract the area around an arrow" {
251+
action x = class
252+
_value {
253+
_vislevel = 3;
254+
255+
width = Scale "Width" 1 40 1;
256+
displace = Scale "Horizontal displace" (-50) 50 0;
257+
vdisplace = Scale "Vertical displace" (-50) 50 0;
258+
259+
_value
260+
= map_unary (extract_arrow
261+
displace.value vdisplace.value width.value) x;
262+
}
263+
}
264+
265+
Hist_plot_item = class
266+
Menuaction "Plot _Object"
267+
"plot an object as a bar, point or line graph" {
268+
action x = class
269+
_result {
270+
_vislevel = 3;
271+
272+
caption = Expression "Chart caption" "none";
273+
format = Option_enum "Format" Plot_format.names "YYYY";
274+
style = Option_enum "Style" Plot_style.names "Line";
275+
276+
auto = Toggle "Auto Range" true;
277+
xmin = Expression "X range minimum" 0;
278+
xmax = Expression "X range maximum" 1;
279+
ymin = Expression "Y range minimum" 0;
280+
ymax = Expression "Y range maximum" 1;
281+
xcaption = Expression "X axis caption" "none";
282+
ycaption = Expression "Y axis caption" "none";
283+
series_captions = Expression "Series captions" ["Band 0"];
284+
285+
_result
286+
= Plot options (image x)
287+
{
288+
options
289+
= [$style => style.value, $format => format.value] ++
290+
range ++ captions;
291+
range
292+
= [], auto
293+
= [$xmin => xmin.expr, $xmax => xmax.expr,
294+
$ymin => ymin.expr, $ymax => ymax.expr];
295+
296+
captions
297+
= concat (map test caption_options) ++
298+
[$series_captions => series_captions.expr]
299+
{
300+
caption_options = [
301+
$caption => caption.expr,
302+
$xcaption => xcaption.expr,
303+
$ycaption => ycaption.expr
304+
];
305+
test x
306+
= [], value == "none"
307+
= [option_name => value]
308+
{
309+
[option_name, value] = x;
310+
}
311+
}
312+
313+
image x
314+
= image (extract_arrow 0 0 1 x), is_Arrow x
315+
= get_image x, has_image x
316+
= x2b im, b == 1
317+
= im
318+
{
319+
im = get_image (to_image x);
320+
w = get_width im;
321+
h = get_height im;
322+
b = get_bands im;
323+
324+
// matrix to image makes a 1-band mxn image
325+
// we need to put columns into bands
326+
x2b im
327+
= bandjoin (map extract_col [0 .. w - 1])
328+
{
329+
extract_col x = extract_area x 0 1 h im;
330+
}
331+
}
332+
}
333+
}
334+
}

0 commit comments

Comments
 (0)