Skip to content

Commit 8d72625

Browse files
committed
Merge branch 'imagej/imagej-ops2/convert-common-image-types' into main
Major changes include: - Refactoring lifting adapters to be genericized instead of hard typed to Img - Better support of Functions with unspecified return types Closes #134 Closes #151
2 parents 54b8af3 + d3d2c39 commit 8d72625

32 files changed

Lines changed: 19843 additions & 1510 deletions

File tree

‎imagej/imagej-ops2/src/main/java/net/imagej/ops2/adapt/LiftComputersToImg.java‎

Lines changed: 0 additions & 101 deletions
This file was deleted.
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
/*
2+
* #%L
3+
* ImageJ2 software for multidimensional image processing and analysis.
4+
* %%
5+
* Copyright (C) 2014 - 2023 ImageJ2 developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
30+
/*
31+
* This is autogenerated source code -- DO NOT EDIT. Instead, edit the
32+
* corresponding template in templates/ and rerun bin/generate.groovy.
33+
*/
34+
35+
package net.imagej.ops2.adapt;
36+
37+
import java.util.function.Function;
38+
39+
import org.scijava.function.Computers;
40+
import org.scijava.function.Functions;
41+
42+
import net.imglib2.RandomAccessibleInterval;
43+
import net.imglib2.loops.LoopBuilder;
44+
import net.imglib2.util.Util;
45+
46+
/**
47+
* Lifts {@link Functions} operating on some types {@code I1, I2, ..., In},
48+
* {@code O extends Type<O>} to a Function operating on
49+
* {@link RandomAccessibleInterval}s of those types. An output
50+
* {@link RandomAccessibleInterval} is created based off of the dimensions of
51+
* the first input image and using the output type of the passed
52+
* {@link Function}. The {@Function}{@code <I, O>} is then applied iteratively
53+
* over each pixel of the input image(s). NOTE: It is assumed that the input
54+
* {@code RAI}s are the same size. If they are not, the lifted {@link Function}
55+
* will only iteratively process the images until one image runs out of pixels
56+
* to iterate over.
57+
*
58+
* @author Gabriel Selzer
59+
* @author Mark Hiner
60+
*/
61+
public class LiftComputersToRAI {
62+
63+
/**
64+
* @implNote op names='adapt', priority='100.'
65+
*/
66+
public static <I1, O, RAII1 extends RandomAccessibleInterval<I1>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity1<RAII1, RAIO> lift11(Computers.Arity1<I1, O> computer) {
67+
return (raiInput1, raiOutput) -> {
68+
LoopBuilder.setImages(raiInput1, raiOutput).multiThreaded() //
69+
.forEachPixel((i1, out) -> computer.compute(i1, out));
70+
};
71+
}
72+
73+
/**
74+
* @implNote op names='adapt', priority='100.'
75+
*/
76+
public static <I1, I2, O, RAII1 extends RandomAccessibleInterval<I1>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity2<RAII1, I2, RAIO> lift21(Computers.Arity2<I1, I2, O> computer) {
77+
return (raiInput1, in2, raiOutput) -> {
78+
LoopBuilder.setImages(raiInput1, raiOutput).multiThreaded() //
79+
.forEachPixel((i1, out) -> computer.compute(i1, in2, out));
80+
};
81+
}
82+
83+
/**
84+
* @implNote op names='adapt', priority='100.'
85+
*/
86+
public static <I1, I2, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity2<RAII1, RAII2, RAIO> lift22(Computers.Arity2<I1, I2, O> computer) {
87+
return (raiInput1, raiInput2, raiOutput) -> {
88+
LoopBuilder.setImages(raiInput1, raiInput2, raiOutput).multiThreaded() //
89+
.forEachPixel((i1, i2, out) -> computer.compute(i1, i2, out));
90+
};
91+
}
92+
93+
/**
94+
* @implNote op names='adapt', priority='100.'
95+
*/
96+
public static <I1, I2, I3, O, RAII1 extends RandomAccessibleInterval<I1>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity3<RAII1, I2, I3, RAIO> lift31(Computers.Arity3<I1, I2, I3, O> computer) {
97+
return (raiInput1, in2, in3, raiOutput) -> {
98+
LoopBuilder.setImages(raiInput1, raiOutput).multiThreaded() //
99+
.forEachPixel((i1, out) -> computer.compute(i1, in2, in3, out));
100+
};
101+
}
102+
103+
/**
104+
* @implNote op names='adapt', priority='100.'
105+
*/
106+
public static <I1, I2, I3, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity3<RAII1, RAII2, I3, RAIO> lift32(Computers.Arity3<I1, I2, I3, O> computer) {
107+
return (raiInput1, raiInput2, in3, raiOutput) -> {
108+
LoopBuilder.setImages(raiInput1, raiInput2, raiOutput).multiThreaded() //
109+
.forEachPixel((i1, i2, out) -> computer.compute(i1, i2, in3, out));
110+
};
111+
}
112+
113+
/**
114+
* @implNote op names='adapt', priority='100.'
115+
*/
116+
public static <I1, I2, I3, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAII3 extends RandomAccessibleInterval<I3>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity3<RAII1, RAII2, RAII3, RAIO> lift33(Computers.Arity3<I1, I2, I3, O> computer) {
117+
return (raiInput1, raiInput2, raiInput3, raiOutput) -> {
118+
LoopBuilder.setImages(raiInput1, raiInput2, raiInput3, raiOutput).multiThreaded() //
119+
.forEachPixel((i1, i2, i3, out) -> computer.compute(i1, i2, i3, out));
120+
};
121+
}
122+
123+
/**
124+
* @implNote op names='adapt', priority='100.'
125+
*/
126+
public static <I1, I2, I3, I4, O, RAII1 extends RandomAccessibleInterval<I1>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity4<RAII1, I2, I3, I4, RAIO> lift41(Computers.Arity4<I1, I2, I3, I4, O> computer) {
127+
return (raiInput1, in2, in3, in4, raiOutput) -> {
128+
LoopBuilder.setImages(raiInput1, raiOutput).multiThreaded() //
129+
.forEachPixel((i1, out) -> computer.compute(i1, in2, in3, in4, out));
130+
};
131+
}
132+
133+
/**
134+
* @implNote op names='adapt', priority='100.'
135+
*/
136+
public static <I1, I2, I3, I4, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity4<RAII1, RAII2, I3, I4, RAIO> lift42(Computers.Arity4<I1, I2, I3, I4, O> computer) {
137+
return (raiInput1, raiInput2, in3, in4, raiOutput) -> {
138+
LoopBuilder.setImages(raiInput1, raiInput2, raiOutput).multiThreaded() //
139+
.forEachPixel((i1, i2, out) -> computer.compute(i1, i2, in3, in4, out));
140+
};
141+
}
142+
143+
/**
144+
* @implNote op names='adapt', priority='100.'
145+
*/
146+
public static <I1, I2, I3, I4, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAII3 extends RandomAccessibleInterval<I3>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity4<RAII1, RAII2, RAII3, I4, RAIO> lift43(Computers.Arity4<I1, I2, I3, I4, O> computer) {
147+
return (raiInput1, raiInput2, raiInput3, in4, raiOutput) -> {
148+
LoopBuilder.setImages(raiInput1, raiInput2, raiInput3, raiOutput).multiThreaded() //
149+
.forEachPixel((i1, i2, i3, out) -> computer.compute(i1, i2, i3, in4, out));
150+
};
151+
}
152+
153+
/**
154+
* @implNote op names='adapt', priority='100.'
155+
*/
156+
public static <I1, I2, I3, I4, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAII3 extends RandomAccessibleInterval<I3>, RAII4 extends RandomAccessibleInterval<I4>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity4<RAII1, RAII2, RAII3, RAII4, RAIO> lift44(Computers.Arity4<I1, I2, I3, I4, O> computer) {
157+
return (raiInput1, raiInput2, raiInput3, raiInput4, raiOutput) -> {
158+
LoopBuilder.setImages(raiInput1, raiInput2, raiInput3, raiInput4, raiOutput).multiThreaded() //
159+
.forEachPixel((i1, i2, i3, i4, out) -> computer.compute(i1, i2, i3, i4, out));
160+
};
161+
}
162+
163+
/**
164+
* @implNote op names='adapt', priority='100.'
165+
*/
166+
public static <I1, I2, I3, I4, I5, O, RAII1 extends RandomAccessibleInterval<I1>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity5<RAII1, I2, I3, I4, I5, RAIO> lift51(Computers.Arity5<I1, I2, I3, I4, I5, O> computer) {
167+
return (raiInput1, in2, in3, in4, in5, raiOutput) -> {
168+
LoopBuilder.setImages(raiInput1, raiOutput).multiThreaded() //
169+
.forEachPixel((i1, out) -> computer.compute(i1, in2, in3, in4, in5, out));
170+
};
171+
}
172+
173+
/**
174+
* @implNote op names='adapt', priority='100.'
175+
*/
176+
public static <I1, I2, I3, I4, I5, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity5<RAII1, RAII2, I3, I4, I5, RAIO> lift52(Computers.Arity5<I1, I2, I3, I4, I5, O> computer) {
177+
return (raiInput1, raiInput2, in3, in4, in5, raiOutput) -> {
178+
LoopBuilder.setImages(raiInput1, raiInput2, raiOutput).multiThreaded() //
179+
.forEachPixel((i1, i2, out) -> computer.compute(i1, i2, in3, in4, in5, out));
180+
};
181+
}
182+
183+
/**
184+
* @implNote op names='adapt', priority='100.'
185+
*/
186+
public static <I1, I2, I3, I4, I5, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAII3 extends RandomAccessibleInterval<I3>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity5<RAII1, RAII2, RAII3, I4, I5, RAIO> lift53(Computers.Arity5<I1, I2, I3, I4, I5, O> computer) {
187+
return (raiInput1, raiInput2, raiInput3, in4, in5, raiOutput) -> {
188+
LoopBuilder.setImages(raiInput1, raiInput2, raiInput3, raiOutput).multiThreaded() //
189+
.forEachPixel((i1, i2, i3, out) -> computer.compute(i1, i2, i3, in4, in5, out));
190+
};
191+
}
192+
193+
/**
194+
* @implNote op names='adapt', priority='100.'
195+
*/
196+
public static <I1, I2, I3, I4, I5, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAII3 extends RandomAccessibleInterval<I3>, RAII4 extends RandomAccessibleInterval<I4>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity5<RAII1, RAII2, RAII3, RAII4, I5, RAIO> lift54(Computers.Arity5<I1, I2, I3, I4, I5, O> computer) {
197+
return (raiInput1, raiInput2, raiInput3, raiInput4, in5, raiOutput) -> {
198+
LoopBuilder.setImages(raiInput1, raiInput2, raiInput3, raiInput4, raiOutput).multiThreaded() //
199+
.forEachPixel((i1, i2, i3, i4, out) -> computer.compute(i1, i2, i3, i4, in5, out));
200+
};
201+
}
202+
203+
/**
204+
* @implNote op names='adapt', priority='100.'
205+
*/
206+
public static <I1, I2, I3, I4, I5, O, RAII1 extends RandomAccessibleInterval<I1>, RAII2 extends RandomAccessibleInterval<I2>, RAII3 extends RandomAccessibleInterval<I3>, RAII4 extends RandomAccessibleInterval<I4>, RAII5 extends RandomAccessibleInterval<I5>, RAIO extends RandomAccessibleInterval<O>> Computers.Arity5<RAII1, RAII2, RAII3, RAII4, RAII5, RAIO> lift55(Computers.Arity5<I1, I2, I3, I4, I5, O> computer) {
207+
return (raiInput1, raiInput2, raiInput3, raiInput4, raiInput5, raiOutput) -> {
208+
LoopBuilder.setImages(raiInput1, raiInput2, raiInput3, raiInput4, raiInput5, raiOutput).multiThreaded() //
209+
.forEachPixel((i1, i2, i3, i4, i5, out) -> computer.compute(i1, i2, i3, i4, i5, out));
210+
};
211+
}
212+
}

0 commit comments

Comments
 (0)