Skip to content

Commit

Permalink
Add start of plotting of cutout
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbieker committed Mar 14, 2020
1 parent 361e8a7 commit 6b16fcc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lofarnn/data/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ def get_lotss_objects(fname, verbose=False):
return Table(table)


def get_panstarrs_download_name(p_download_loc, f_ra, f_dec, p_size, filter):
"""
Get the download name of a PanSTARRS fits file in a fixed format
"""
return f'{p_download_loc}ra={f_ra}_dec={f_dec}_s={p_size}_{filter}.fits'


def create_coco_annotations(image_names,
image_dir='images', image_destination_dir=None,
json_dir='', json_name='json_data.pkl', image_size=None,
Expand Down Expand Up @@ -414,7 +407,8 @@ def create_fixed_cutouts(mosaic, value_added_catalog, pan_wise_catalog, mosaic_l


def create_fixed_source_dataset(cutout_directory, pan_wise_location,
value_added_catalog_location, dr_two_location, fixed_size=300, use_multiprocessing=False,
value_added_catalog_location, dr_two_location, fixed_size=300,
use_multiprocessing=False,
num_threads=os.cpu_count()):
"""
Creates fixed size dataset using LGZ data
Expand Down
25 changes: 25 additions & 0 deletions lofarnn/visualization/cutouts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import matplotlib.patches as patches
import matplotlib.pyplot as plt
import numpy as np


def plot_cutout_and_bbox(image_name, title):
"""
:param image_name:
:param title:
:return:
"""

cutout_and_bboxes = np.load(image_name)
cutout = cutout_and_bboxes[0]
bboxes = cutout_and_bboxes[1]
fig,ax = plt.subplots(1)
if cutout.shape[2] == 3:
ax.imshow(cutout)

for bbox in bboxes:
rect = patches.Rectangle((bbox[0], bbox[1]), 1, 1, linewidth=1, edgecolor='r', facecolor='none')
ax.add_patch(rect)

plt.show()

0 comments on commit 6b16fcc

Please sign in to comment.