Exemple #1
0
    ax0.axis('off')
    ax1.axis('off')
    ax0.set_aspect('equal')
    ax1.set_aspect('equal')

  # Start processing the image.
  print 'processing "%s"..' % filepath
  piece = JigsawPiece(filepath)
  if args['--plot']:
    ax0.imshow(piece.raw_image, aspect='equal')
  piece_data[filepath] = {}
  piece_data[filepath]['raw_image'] = piece.raw_image.tolist()

  # Get contours.
  try:
    piece.segment(low_threshold=low_threshold, high_threshold=high_threshold)
    if args['--plot']:
      ax0.plot(piece.outline[:, 0], -piece.outline[:, 1], color='green')
      ax1.plot(piece.outline[:, 0], piece.outline[:, 1], color='gray')
    piece_data[filepath]['outline'] = piece.outline.tolist()
  except:
    print 'could not find contours for "%s"' % filepath

  # Set the raw image's axis limits to match the derived data's axis.
  if args['--plot']:
    ax0.axes.set_xlim(ax1.axes.get_xlim())
    y_min, y_max = ax1.axes.get_ylim()
    ax0.axes.set_ylim((-y_min, -y_max))

  # Save the figure.
  filename = os.path.basename(filepath)
Exemple #2
0
    ax1 = plt.subplot(figure_grid[0, 1])
    ax0.axis('off')
    ax1.axis('off')
    ax0.set_aspect('equal')
    ax1.set_aspect('equal')

  # Start processing the image.
  print 'processing "%s"..' % filepath
  piece = JigsawPiece(filepath)
  if args['--plot']:
    ax0.imshow(piece.raw_image, aspect='equal')
  piece_data['raw_image'] = piece.raw_image.tolist()

  # Get contours.
  try:
    piece.segment()
    if args['--plot']:
      ax0.plot(piece.outline[:, 0], -piece.outline[:, 1], color='green')
      ax1.plot(piece.outline[:, 0], piece.outline[:, 1], color='gray')
    piece_data['outline'] = piece.outline.tolist()
  except:
    print 'could not find contours for "%s"' % filepath

  # Set the raw image's axis limits to match the derived data's axis.
  if args['--plot']:
    ax0.axes.set_xlim(ax1.axes.get_xlim())
    y_min, y_max = ax1.axes.get_ylim()
    ax0.axes.set_ylim((-y_min, -y_max))

  # Find the center.
  try: