Exemplo n.º 1
0
 def test_01_09_jdictionary_to_string_dictionary(self):
     properties = J.static_call("java/lang/System", "getProperties",
                                "()Ljava/util/Properties;")
     d = J.get_dictionary_wrapper(properties)
     pyd = J.jdictionary_to_string_dictionary(properties)
     keys = J.jenumeration_to_string_list(d.keys())
     for key in keys:
         value = J.to_string(d.get(key))
         self.assertEqual(pyd[key], value)
Exemplo n.º 2
0
 def test_01_09_jdictionary_to_string_dictionary(self):
     properties = J.static_call("java/lang/System", "getProperties",
                                "()Ljava/util/Properties;")
     d = J.get_dictionary_wrapper(properties)
     pyd = J.jdictionary_to_string_dictionary(properties)
     keys = J.jenumeration_to_string_list(d.keys())
     for key in keys:
         value = J.to_string(d.get(key))
         self.assertEqual(pyd[key], value)
Exemplo n.º 3
0
 def OnInit(self):
     self.PrintMode = 0
     dlg = wx.FileDialog(None)
     if dlg.ShowModal()==wx.ID_OK:
         rdr = ImageReader()
         rdr.setId(dlg.Path)
         print "Format = %s"%rdr.getFormat()
         w = rdr.getSizeX()
         h = rdr.getSizeY()
         pixel_type = rdr.getPixelType()
         little_endian = rdr.isLittleEndian()
         metadata = rdr.getMetadata()
         d = jutil.jdictionary_to_string_dictionary(metadata)
         for key in d.keys():
             print key+"="+d[key]
         if pixel_type == FormatTools.INT8:
             dtype = np.char
         elif pixel_type == FormatTools.UINT8:
             dtype = np.uint8
         elif pixel_type == FormatTools.UINT16:
             dtype = '<u2' if little_endian else '>u2'
         elif pixel_type == FormatTools.INT16:
             dtype = '<i2' if little_endian else '>i2'
         elif pixel_type == FormatTools.UINT32:
             dtype = '<u4' if little_endian else '>u4'
         elif pixel_type == FormatTools.INT32:
             dtype = '<i4' if little_endian else '>i4'
         elif pixel_type == FormatTools.FLOAT:
             dtype = '<f4' if little_endian else '>f4'
         elif pixel_type == FormatTools.DOUBLE:
             dtype = '<f8' if little_endian else '>f8'
             
         if rdr.getRGBChannelCount() > 1:
             rdr.close()
             rdr = ChannelSeparator(ImageReader())
             rdr.setId(dlg.Path)
             red_image, green_image, blue_image = [
                 np.frombuffer(rdr.openBytes(rdr.getIndex(0,i,0)),dtype)
                 for i in range(3)]
             image = np.dstack((red_image, green_image, blue_image))
             image.shape=(h,w,3)
         else:
             image = np.frombuffer(rdr.openBytes(0),dtype)
             image.shape = (h,w)
         rdr.close()
         fig = mmmm.Figure()
         axes = fig.add_subplot(1,1,1)
         axes.imshow(image)
         frame = mmmm.FigureFrameWxAgg(1,fig)
         frame.Show()
         return True
     return False
 def test_02_01_make_image_reader(self):
     path = os.path.join(example_images_directory(), "ExampleSBSImages", "Channel1-01-A-01.tif")
     ImageReader = F.make_image_reader_class()
     FormatTools = F.make_format_tools_class()
     reader = ImageReader()
     reader.setId(path)
     self.assertEqual(reader.getDimensionOrder(), "XYCZT")
     metadata = J.jdictionary_to_string_dictionary(reader.getMetadata())
     self.assertEqual(int(metadata["ImageWidth"]), reader.getSizeX())
     self.assertEqual(int(metadata["ImageLength"]), reader.getSizeY())
     self.assertEqual(reader.getImageCount(), 1)
     self.assertEqual(reader.getSizeC(), 1)
     self.assertEqual(reader.getSizeT(), 1)
     self.assertEqual(reader.getSizeZ(), 1)
     self.assertEqual(reader.getPixelType(), FormatTools.UINT8)
     self.assertEqual(reader.getRGBChannelCount(), 1)
Exemplo n.º 5
0
 def test_02_01_make_image_reader(self):
     path = os.path.join(example_images_directory(), 'ExampleSBSImages',
                         'Channel1-01-A-01.tif')
     ImageReader = F.make_image_reader_class()
     FormatTools = F.make_format_tools_class()
     reader = ImageReader()
     reader.setId(path)
     self.assertEqual(reader.getDimensionOrder(), "XYCZT")
     metadata = J.jdictionary_to_string_dictionary(reader.getMetadata())
     self.assertEqual(int(metadata["ImageWidth"]), reader.getSizeX())
     self.assertEqual(int(metadata["ImageLength"]), reader.getSizeY())
     self.assertEqual(reader.getImageCount(), 1)
     self.assertEqual(reader.getSizeC(), 1)
     self.assertEqual(reader.getSizeT(), 1)
     self.assertEqual(reader.getSizeZ(), 1)
     self.assertEqual(reader.getPixelType(), FormatTools.UINT8)
     self.assertEqual(reader.getRGBChannelCount(), 1)