Ejemplo n.º 1
0
 def _read(self, idx):
     image = datasets.imread_rgb(os.path.join(self._root, 
                                 "Images", self._data[idx]))
     if self._crop != False:
         imheight, imwidth = image.shape[:2]
         annotation = ET.parse(os.path.join(self._root, 
                 "Annotation", self._data[idx][:-4])).getroot()
         objects = [c for c in annotation if c.tag == "object"]
         bbox = objects[0].find('bndbox')
         xmin = int(bbox.find('xmin').text) - 1
         ymin = int(bbox.find('ymin').text) - 1
         xmax = int(bbox.find('xmax').text)
         ymax = int(bbox.find('ymax').text)
         # expand
         width = xmax - xmin
         height = ymax - ymin
         centerx = xmin + width / 2.
         centery = ymin + height / 2.
         xoffset = width * self._crop / 2.
         yoffset = height * self._crop / 2.
         xmin = max(int(centerx - xoffset + 0.5), 0)
         ymin = max(int(centery - yoffset + 0.5), 0)
         xmax = min(int(centerx + xoffset + 0.5), imwidth - 1)
         ymax = min(int(centery + yoffset + 0.5), imheight - 1)
         image = image[ymin:ymax, xmin:xmax].copy()
     if self._target_size is not None:
         image = misc.imresize(image, self._target_size)
     return image
Ejemplo n.º 2
0
 def _read(self, idx):
     image = datasets.imread_rgb(
         os.path.join(self._root, "Images", self._data[idx]))
     if self._crop != False:
         imheight, imwidth = image.shape[:2]
         annotation = ET.parse(
             os.path.join(self._root, "Annotation",
                          self._data[idx][:-4])).getroot()
         objects = [c for c in annotation if c.tag == "object"]
         bbox = objects[0].find('bndbox')
         xmin = int(bbox.find('xmin').text) - 1
         ymin = int(bbox.find('ymin').text) - 1
         xmax = int(bbox.find('xmax').text)
         ymax = int(bbox.find('ymax').text)
         # expand
         width = xmax - xmin
         height = ymax - ymin
         centerx = xmin + width / 2.
         centery = ymin + height / 2.
         xoffset = width * self._crop / 2.
         yoffset = height * self._crop / 2.
         xmin = max(int(centerx - xoffset + 0.5), 0)
         ymin = max(int(centery - yoffset + 0.5), 0)
         xmax = min(int(centerx + xoffset + 0.5), imwidth - 1)
         ymax = min(int(centery + yoffset + 0.5), imheight - 1)
         image = image[ymin:ymax, xmin:xmax].copy()
     if self._target_size is not None:
         image = misc.imresize(image, self._target_size)
     return image
Ejemplo n.º 3
0
 def _read(self, idx):
     image = datasets.imread_rgb(self._data[idx])
     self._raw_dimension[idx] = image.shape[:2]
     xmin, ymin, xmax, ymax = \
                 self._get_cropped_coordinates(idx)
     image = image[ymin:ymax, xmin:xmax].copy()
     if self._target_size is not None:
         image = misc.imresize(image, self._target_size)
     return image
Ejemplo n.º 4
0
 def _read(self, idx):
     image = datasets.imread_rgb(os.path.join(self._root, 'images',\
                                              self._raw_name[idx]))
     self._raw_dimension[idx] = image.shape[:2]
     xmin, ymin, xmax, ymax = \
                 self._get_cropped_coordinates(idx)
     image = image[ymin:ymax, xmin:xmax].copy()
     if self._target_size is not None:
         image = misc.imresize(image, self._target_size)
     return image
Ejemplo n.º 5
0
 def read_image(self, name):
     """Reads the image and does the manipulation
     """
     img = datasets.imread_rgb(name)
     return datasets.manipulate(img, None, None, None, CENTER_CROP)
 def read_image(self, name):
     """Reads the image and does the manipulation
     """
     img = datasets.imread_rgb(name)
     return datasets.manipulate(img, None, None, None, CENTER_CROP)