@@ -24,7 +24,7 @@ function apply(crop::Crop, item::Item; randstate = getrandstate(crop))
24
24
return apply (
25
25
Project (CoordinateTransformations. IdentityTransformation ()) |> crop,
26
26
item;
27
- randstate = (nothing , randstate))
27
+ randstate = (nothing , ( randstate,) ))
28
28
end
29
29
30
30
50
50
51
51
52
52
53
- struct CroppedProjectiveTransform{P<: ProjectiveTransform , C<: AbstractCrop } <: ProjectiveTransform
53
+ struct CroppedProjectiveTransform{P<: ProjectiveTransform , C<: Tuple } <: ProjectiveTransform
54
54
tfm:: P
55
- crop :: C
55
+ crops :: C
56
56
end
57
57
58
58
59
59
function getrandstate (cropped:: CroppedProjectiveTransform )
60
- return (getrandstate (cropped. tfm), getrandstate (cropped. crop ))
60
+ return (getrandstate (cropped. tfm), getrandstate . (cropped. crops ))
61
61
end
62
62
63
63
@@ -69,49 +69,55 @@ function getprojection(
69
69
return getprojection (cropped. tfm, bounds; randstate = tfmstate)
70
70
end
71
71
72
-
73
72
function projectionbounds (
74
- cropped:: CroppedProjectiveTransform{PT, C} ,
73
+ cropped:: CroppedProjectiveTransform ,
75
74
P,
76
75
bounds;
77
- randstate = getrandstate (cropped)) where {PT, C <: Crop }
78
- tfmstate, cropstate = randstate
76
+ randstate = getrandstate (cropped))
77
+ tfmstate, cropstates = randstate
79
78
bounds_ = projectionbounds (cropped. tfm, P, bounds; randstate = tfmstate)
80
- return offsetcropbounds (cropped. crop. size, bounds_, cropstate)
79
+ for (crop, cropstate) in zip (cropped. crops, cropstates)
80
+ bounds_ = cropbounds (crop, bounds_; randstate = cropstate)
81
+ end
82
+ return bounds_
81
83
end
82
84
85
+ compose (tfm:: ProjectiveTransform , crop:: AbstractCrop ) = CroppedProjectiveTransform (tfm, (crop,))
86
+ compose (tfm:: ProjectiveTransform , cropped:: CroppedProjectiveTransform ) =
87
+ CroppedProjectiveTransform (tfm |> cropped. tfm, cropped. crops)
83
88
84
- function projectionbounds (
85
- cropped:: CroppedProjectiveTransform{PT, PadDivisible} ,
86
- P,
87
- bounds;
88
- randstate = getrandstate (cropped)) where {PT}
89
- tfmstate, cropstate = randstate
90
- bounds_ = projectionbounds (cropped. tfm, P, bounds; randstate = tfmstate)
91
- ranges = bounds_. rs
89
+ function compose (composed:: ComposedProjectiveTransform , cropped:: CroppedProjectiveTransform )
90
+ return CroppedProjectiveTransform (composed |> cropped. tfm, cropped. crops)
91
+ end
92
92
93
- sz = length .(ranges)
94
- pad = (cropped. crop. by .- (sz .% cropped. crop. by)) .% cropped. crop. by
93
+ function compose (cropped:: CroppedProjectiveTransform , crop:: AbstractCrop )
94
+ return CroppedProjectiveTransform (cropped. tfm, (cropped. crops... , crop))
95
+ end
95
96
96
- start = minimum .(ranges)
97
- end_ = start .+ sz .+ pad .- 1
98
- rs = UnitRange .(start, end_)
99
- return Bounds (rs)
97
+ function compose (cropped:: CroppedProjectiveTransform , projective:: ProjectiveTransform )
98
+ return Sequence (cropped, projective)
100
99
end
101
100
101
+ function compose (cropped:: CroppedProjectiveTransform , composed:: ComposedProjectiveTransform )
102
+ return Sequence (cropped, composed)
103
+ end
102
104
103
105
104
- compose (tfm:: ProjectiveTransform , crop:: AbstractCrop ) = CroppedProjectiveTransform (tfm, crop)
105
- compose (tfm:: ProjectiveTransform , crop:: CroppedProjectiveTransform ) =
106
- CroppedProjectiveTransform (tfm |> crop. tfm, crop. crop)
106
+ cropbounds (crop:: Crop , bounds:: Bounds ; randstate= getrandstate (crop)) = offsetcropbounds (crop. size, bounds, randstate)
107
107
108
- function compose (composed:: ComposedProjectiveTransform , cropped:: CroppedProjectiveTransform )
109
- return CroppedProjectiveTransform (composed |> cropped. tfm, cropped. crop)
108
+ function cropbounds (
109
+ crop:: PadDivisible ,
110
+ bounds:: Bounds ;
111
+ randstate = getrandstate (crop))
112
+ ranges = bounds. rs
110
113
111
- end
114
+ sz = length .(ranges)
115
+ pad = (crop. by .- (sz .% crop. by)) .% crop. by
112
116
113
- function compose (cropped:: CroppedProjectiveTransform , projective:: ProjectiveTransform )
114
- return Sequence (cropped, projective)
117
+ start = minimum .(ranges)
118
+ end_ = start .+ sz .+ pad .- 1
119
+ rs = UnitRange .(start, end_)
120
+ return Bounds (rs)
115
121
end
116
122
117
123
0 commit comments