@@ -30,9 +30,6 @@ public VolumeDataset Import()
30
30
31
31
List < string > imagePaths = GetSortedImagePaths ( ) ;
32
32
33
- if ( ! ImageSetHasUniformDimensions ( imagePaths ) )
34
- throw new IndexOutOfRangeException ( "Image sequence has non-uniform dimensions" ) ;
35
-
36
33
Vector3Int dimensions = GetVolumeDimensions ( imagePaths ) ;
37
34
int [ ] data = FillSequentialData ( dimensions , imagePaths ) ;
38
35
VolumeDataset dataset = FillVolumeDataset ( data , dimensions ) ;
@@ -60,34 +57,6 @@ private List<string> GetSortedImagePaths()
60
57
return imagePaths ;
61
58
}
62
59
63
- /// <summary>
64
- /// Checks if every image in the set has the same XY dimensions.
65
- /// </summary>
66
- /// <param name="imagePaths">The list of image paths to check.</param>
67
- /// <returns>True if at least one image differs from another.</returns>
68
- private bool ImageSetHasUniformDimensions ( List < string > imagePaths )
69
- {
70
- bool hasUniformDimension = true ;
71
-
72
- Vector2Int previous , current ;
73
- previous = GetImageDimensions ( imagePaths [ 0 ] ) ;
74
-
75
- foreach ( var path in imagePaths )
76
- {
77
- current = GetImageDimensions ( path ) ;
78
-
79
- if ( current . x != previous . x || current . y != previous . y )
80
- {
81
- hasUniformDimension = false ;
82
- break ;
83
- }
84
-
85
- previous = current ;
86
- }
87
-
88
- return hasUniformDimension ;
89
- }
90
-
91
60
/// <summary>
92
61
/// Gets the XY dimensions of an image at the path.
93
62
/// </summary>
@@ -142,6 +111,12 @@ private int[] FillSequentialData(Vector3Int dimensions, List<string> paths)
142
111
byte [ ] bytes = File . ReadAllBytes ( path ) ;
143
112
texture . LoadImage ( bytes ) ;
144
113
114
+ if ( texture . width != dimensions . x || texture . height != dimensions . y )
115
+ {
116
+ Texture2D . DestroyImmediate ( texture ) ;
117
+ throw new IndexOutOfRangeException ( "Image sequence has non-uniform dimensions" ) ;
118
+ }
119
+
145
120
Color [ ] pixels = texture . GetPixels ( ) ; // Order priority: X -> Y -> Z
146
121
int [ ] imageData = DensityHelper . ConvertColorsToDensities ( pixels ) ;
147
122
@@ -177,4 +152,4 @@ private VolumeDataset FillVolumeDataset(int[] data, Vector3Int dimensions)
177
152
return dataset ;
178
153
}
179
154
}
180
- }
155
+ }
0 commit comments