bm_dataset.create_real_synth_dataset module

Script for generating synthetic datasets from a single image and landmarks. The output is set of geometrical deformed images with also change color space and related computed new landmarks.

Sample run:

python create_real_synth_dataset.py         -i ../data_images/images/Rat-Kidney_HE.jpg         -l ../data_images/landmarks/Rat-Kidney_HE.csv         -o ../output/synth_dataset  --visual

Copyright (C) 2016-2019 Jiri Borovec <jiri.borovec@fel.cvut.cz>

bm_dataset.create_real_synth_dataset.arg_parse_params()[source]

parse the input parameters :return dict: parameters

bm_dataset.create_real_synth_dataset.deform_image_landmarks(image, points, max_deform=50)[source]

deform the image by randomly generated deformation field and compute new positions for all landmarks

Parameters:
  • image – np.array<height, width, 3>
  • points – np.array<nb_points, 2>
  • max_deform (float) – maximal deformation distance in any direction
Returns:

np.array<height, width, 3>, np.array<nb_points, 2>

bm_dataset.create_real_synth_dataset.draw_image_landmarks(image, points)[source]

draw landmarks over the image and return the figure

Parameters:
  • image – np.array<height, width, 3>
  • points – np.array<nb_points, 2>
Returns:

object

bm_dataset.create_real_synth_dataset.export_image_landmarks(image, points, idx, path_out, name_img, visual=False)[source]

export the image, landmarks as csv file and if the ‘visual’ is set, draw also landmarks in the image (in separate image)

Parameters:
  • image – np.array<height, width, 3>
  • points – np.array<nb_points, 2>
  • idx (int) –
  • path_out (str) – path to the output directory
  • name_img (str) – image file name
  • visual (bool) –
bm_dataset.create_real_synth_dataset.generate_deformation_field_gauss(shape, points, max_deform=50, deform_smooth=25)[source]

generate deformation field as combination of positive and negative Galatians densities scaled in range +/- max_deform

Parameters:
  • shape (tuple(int,int)) – tuple of size 2
  • points – <nb_points, 2> list of landmarks
  • max_deform (float) – maximal deformation distance in any direction
  • deform_smooth (float) – smoothing the deformation by Gaussian filter
Returns:

np.array<shape>

bm_dataset.create_real_synth_dataset.generate_deformation_field_rbf(shape, points, max_deform=50, nb_bound_points=25)[source]

generate deformation field as thin plate spline deformation in range +/- max_deform

Parameters:
  • shape (tuple(int,int)) – tuple of size 2
  • points – np.array<nb_points, 2> list of landmarks
  • max_deform (float) – maximal deformation distance in any direction
  • nb_bound_points (int) – number of fix boundary points
Returns:

np.array<shape>

bm_dataset.create_real_synth_dataset.get_name(path)[source]

parse the name without extension from complete path

Parameters:path (str) –
Return str:
bm_dataset.create_real_synth_dataset.image_color_shift_hue(image, change_satur=True)[source]

take the original image and shift the colour space in HUE

Parameters:
  • image – np.array<height, width, 3>
  • change_satur (bool) – whether change also the saturation
Returns:

np.array<height, width, 3>

bm_dataset.create_real_synth_dataset.main(params)[source]

main entry point

Parameters:params (dict) – dict
bm_dataset.create_real_synth_dataset.perform_deform_export(idx, image, points, path_out, name_img, visual=False)[source]

perform complete image colour change, and deformation on image and landmarks and if required draw a visualisation

Parameters:
  • idx (int) –
  • image – np.array<height, width, 3>
  • points – np.array<nb_points, 2>
  • path_out (str) –
  • name_img (str) –
  • visual (bool) –