@@ -60,27 +60,27 @@ def close(self):
60
60
raise NotImplementedError
61
61
62
62
@property
63
- def layer_count (self ):
64
- """The number of layers in the image."""
63
+ def level_count (self ):
64
+ """The number of levels in the image."""
65
65
raise NotImplementedError
66
66
67
67
@property
68
- def layer_dimensions (self ):
69
- """A list of (width, height) tuples, one for each layer of the image.
68
+ def level_dimensions (self ):
69
+ """A list of (width, height) tuples, one for each level of the image.
70
70
71
- layer_dimensions [n] contains the dimensions of layer n."""
71
+ level_dimensions [n] contains the dimensions of level n."""
72
72
raise NotImplementedError
73
73
74
74
@property
75
75
def dimensions (self ):
76
- """A (width, height) tuple for layer 0 of the image."""
77
- return self .layer_dimensions [0 ]
76
+ """A (width, height) tuple for level 0 of the image."""
77
+ return self .level_dimensions [0 ]
78
78
79
79
@property
80
- def layer_downsamples (self ):
81
- """A list of downsampling factors for each layer of the image.
80
+ def level_downsamples (self ):
81
+ """A list of downsampling factors for each level of the image.
82
82
83
- layer_downsample [n] contains the downsample factor of layer n."""
83
+ level_downsample [n] contains the downsample factor of level n."""
84
84
raise NotImplementedError
85
85
86
86
@property
@@ -97,16 +97,16 @@ def associated_images(self):
97
97
This is a map: image name -> PIL.Image."""
98
98
raise NotImplementedError
99
99
100
- def get_best_layer_for_downsample (self , downsample ):
101
- """Return the best layer for displaying the given downsample."""
100
+ def get_best_level_for_downsample (self , downsample ):
101
+ """Return the best level for displaying the given downsample."""
102
102
raise NotImplementedError
103
103
104
- def read_region (self , location , layer , size ):
104
+ def read_region (self , location , level , size ):
105
105
"""Return a PIL.Image containing the contents of the region.
106
106
107
- location: (x, y) tuple giving the top left pixel in the layer 0
107
+ location: (x, y) tuple giving the top left pixel in the level 0
108
108
reference frame.
109
- layer : the layer number.
109
+ level : the level number.
110
110
size: (width, height) tuple giving the region size."""
111
111
raise NotImplementedError
112
112
@@ -116,8 +116,8 @@ def get_thumbnail(self, size):
116
116
size: the maximum size of the thumbnail."""
117
117
downsample = max (* [dim / thumb for dim , thumb in
118
118
zip (self .dimensions , size )])
119
- layer = self .get_best_layer_for_downsample (downsample )
120
- tile = self .read_region ((0 , 0 ), layer , self .layer_dimensions [ layer ])
119
+ level = self .get_best_level_for_downsample (downsample )
120
+ tile = self .read_region ((0 , 0 ), level , self .level_dimensions [ level ])
121
121
# Apply on solid background
122
122
bg_color = '#' + self .properties .get (PROPERTY_NAME_BACKGROUND_COLOR ,
123
123
'ffffff' )
@@ -154,25 +154,25 @@ def close(self):
154
154
lowlevel .close (self ._osr )
155
155
156
156
@property
157
- def layer_count (self ):
158
- """The number of layers in the image."""
159
- return lowlevel .get_layer_count (self ._osr )
157
+ def level_count (self ):
158
+ """The number of levels in the image."""
159
+ return lowlevel .get_level_count (self ._osr )
160
160
161
161
@property
162
- def layer_dimensions (self ):
163
- """A list of (width, height) tuples, one for each layer of the image.
162
+ def level_dimensions (self ):
163
+ """A list of (width, height) tuples, one for each level of the image.
164
164
165
- layer_dimensions [n] contains the dimensions of layer n."""
166
- return tuple (lowlevel .get_layer_dimensions (self ._osr , i )
167
- for i in range (self .layer_count ))
165
+ level_dimensions [n] contains the dimensions of level n."""
166
+ return tuple (lowlevel .get_level_dimensions (self ._osr , i )
167
+ for i in range (self .level_count ))
168
168
169
169
@property
170
- def layer_downsamples (self ):
171
- """A list of downsampling factors for each layer of the image.
170
+ def level_downsamples (self ):
171
+ """A list of downsampling factors for each level of the image.
172
172
173
- layer_downsample [n] contains the downsample factor of layer n."""
174
- return tuple (lowlevel .get_layer_downsample (self ._osr , i )
175
- for i in range (self .layer_count ))
173
+ level_downsample [n] contains the downsample factor of level n."""
174
+ return tuple (lowlevel .get_level_downsample (self ._osr , i )
175
+ for i in range (self .level_count ))
176
176
177
177
@property
178
178
def properties (self ):
@@ -191,22 +191,22 @@ def associated_images(self):
191
191
are not premultiplied."""
192
192
return _AssociatedImageMap (self ._osr )
193
193
194
- def get_best_layer_for_downsample (self , downsample ):
195
- """Return the best layer for displaying the given downsample."""
196
- return lowlevel .get_best_layer_for_downsample (self ._osr , downsample )
194
+ def get_best_level_for_downsample (self , downsample ):
195
+ """Return the best level for displaying the given downsample."""
196
+ return lowlevel .get_best_level_for_downsample (self ._osr , downsample )
197
197
198
- def read_region (self , location , layer , size ):
198
+ def read_region (self , location , level , size ):
199
199
"""Return a PIL.Image containing the contents of the region.
200
200
201
- location: (x, y) tuple giving the top left pixel in the layer 0
201
+ location: (x, y) tuple giving the top left pixel in the level 0
202
202
reference frame.
203
- layer : the layer number.
203
+ level : the level number.
204
204
size: (width, height) tuple giving the region size.
205
205
206
206
Unlike in the C interface, the image data returned by this
207
207
function is not premultiplied."""
208
208
return lowlevel .read_region (self ._osr , location [0 ], location [1 ],
209
- layer , size [0 ], size [1 ])
209
+ level , size [0 ], size [1 ])
210
210
211
211
212
212
class _OpenSlideMap (Mapping ):
@@ -274,22 +274,22 @@ def close(self):
274
274
self ._image = None
275
275
276
276
@property
277
- def layer_count (self ):
278
- """The number of layers in the image."""
277
+ def level_count (self ):
278
+ """The number of levels in the image."""
279
279
return 1
280
280
281
281
@property
282
- def layer_dimensions (self ):
283
- """A list of (width, height) tuples, one for each layer of the image.
282
+ def level_dimensions (self ):
283
+ """A list of (width, height) tuples, one for each level of the image.
284
284
285
- layer_dimensions [n] contains the dimensions of layer n."""
285
+ level_dimensions [n] contains the dimensions of level n."""
286
286
return (self ._image .size ,)
287
287
288
288
@property
289
- def layer_downsamples (self ):
290
- """A list of downsampling factors for each layer of the image.
289
+ def level_downsamples (self ):
290
+ """A list of downsampling factors for each level of the image.
291
291
292
- layer_downsample [n] contains the downsample factor of layer n."""
292
+ level_downsample [n] contains the downsample factor of level n."""
293
293
return (1.0 ,)
294
294
295
295
@property
@@ -306,19 +306,19 @@ def associated_images(self):
306
306
This is a map: image name -> PIL.Image."""
307
307
return {}
308
308
309
- def get_best_layer_for_downsample (self , _downsample ):
310
- """Return the best layer for displaying the given downsample."""
309
+ def get_best_level_for_downsample (self , _downsample ):
310
+ """Return the best level for displaying the given downsample."""
311
311
return 0
312
312
313
- def read_region (self , location , layer , size ):
313
+ def read_region (self , location , level , size ):
314
314
"""Return a PIL.Image containing the contents of the region.
315
315
316
- location: (x, y) tuple giving the top left pixel in the layer 0
316
+ location: (x, y) tuple giving the top left pixel in the level 0
317
317
reference frame.
318
- layer : the layer number.
318
+ level : the level number.
319
319
size: (width, height) tuple giving the region size."""
320
- if layer != 0 :
321
- raise OpenSlideError ("Invalid layer " )
320
+ if level != 0 :
321
+ raise OpenSlideError ("Invalid level " )
322
322
if ['fail' for s in size if s < 0 ]:
323
323
raise OpenSlideError ("Size %s must be non-negative" % (size ,))
324
324
# Any corner of the requested region may be outside the bounds of
@@ -358,8 +358,8 @@ def open_slide(filename):
358
358
print "PIL can open:" , ImageSlide .can_open (sys .argv [1 ])
359
359
with open_slide (sys .argv [1 ]) as _slide :
360
360
print "Dimensions:" , _slide .dimensions
361
- print "Layers :" , _slide .layer_count
362
- print "Layer dimensions:" , _slide .layer_dimensions
363
- print "Layer downsamples:" , _slide .layer_downsamples
361
+ print "Levels :" , _slide .level_count
362
+ print "Level dimensions:" , _slide .level_dimensions
363
+ print "Level downsamples:" , _slide .level_downsamples
364
364
print "Properties:" , _slide .properties
365
365
print "Associated images:" , _slide .associated_images
0 commit comments