How to use _open_image_file method in ATX

Best Python code snippet using ATX

yapic_dependencies.py

Source:yapic_dependencies.py Github

copy

Full Screen

...74 self.labelvalue_mapping = self.calc_label_values_mapping(75 original_labels)76 self.check_label_matrix_dimensions()77 @lru_cache(maxsize=10)78 def _open_image_file(self, image_nr):79 """No memmap required when using the napari viewer."""80 im_name = self.filenames[image_nr].img81 data = self.data[im_name].data82 if not self.data[im_name].rgb: # image has no channel dim83 data = np.expand_dims(data, axis=-1) # channel dim84 # adding the four dimensions (z, y, x, c)85 if len(data.shape) == 3: # RGB image (z, y, x, c)86 data = np.expand_dims(data, axis=0) # z dim87 # arranging desired dimensions (c, z, x, y)88 data = np.moveaxis(data, (0, 1, 3), (1, 3, 0))89 return data90 def image_dimensions(self, image_nr):91 img = self._open_image_file(image_nr)92 return img.shape93 def original_label_values_for_all_images(self):94 """Empty return since no label path is required."""95 return []96 def _assemble_filenames(self, pairs):97 self.filenames = [FilePair(img, Path(lbl) if lbl else None)98 for img, lbl in pairs]99 def check_label_matrix_dimensions(self):100 """True return since label path is not required"""101 return True102 @lru_cache(maxsize=10)103 def _open_label_file(self, image_nr):104 """No label path required"""105 return None106 def get_tile(self, image_nr, pos, size):107 """Modification from TiffConnector to get a tile from numpy array."""108 C, Z, X, Y = pos109 CC, ZZ, XX, YY = np.array(pos) + size # offset110 slices = self._open_image_file(image_nr)111 tile = slices[C:CC, Z: ZZ, X: XX, Y: YY]112 return tile.astype('float')113 @lru_cache(maxsize=10)114 def _open_probability_map_file(self,115 image_nr,116 label_value,117 multichannel=False):118 """Minor change in the file and path definition."""119 # memmap is slow, so we must cache it to be fast!120 fname = self.filenames[image_nr].img121 if multichannel:122 fname = Path('{}.tif'.format(fname))123 n_classes = multichannel124 C = n_classes...

Full Screen

Full Screen

ImageSize.py

Source:ImageSize.py Github

copy

Full Screen

...4 Providses size information and crop / resize tools for images5 """6 def __init__(self):7 pass8 def _open_image_file(function):9 """10 Decorator to open image file11 """12 def read_image(image_file, *args):13 try:14 image = Image.open(image_file)15 return function(image, *args)16 except IOError:17 return 'Error opening file'18 return read_image19 @staticmethod20 @_open_image_file21 def get_image_size(image):22 """...

Full Screen

Full Screen

tests.py

Source:tests.py Github

copy

Full Screen

1from django.core.urlresolvers import reverse2from django.test import TestCase3# Create your tests here.4class FileUploadTests(TestCase):5 def _open_image_file(self):6 f = open('/home/randolph/Pictures/weed.jpg', 'rb')7 return f8 def _create_test_file(self, path):9 f = open(path, 'w')10 f.write('test123\n')11 f.close()12 f = open(path, 'rb')13 return {14 'doc': f,15 }16 def test_upload_file(self):17 url = reverse('task-list')18 data = self._create_test_file('/tmp/test_upload')19 data['task_name'] = 't1'20 data['task_desc'] = 'test'21 data['image'] = self._open_image_file()22 print data23 response = self.client.post(url, data, format='multipart')24 print response.status_code25 print response.content26 # # assert authenticated user can upload file27 # token = Token.objects.get(user__username='test')28 # client = APIClient()29 # client.credentials(HTTP_AUTHORIZATION='Token ' + token.key)30 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful