DiPNG

Dicom to PNG converter and Image Viewer

DiPNG is a web application which converts a Dicom file into a PNG file. It also has a viewer for the converted PNG file.

Python
HTML
CSS
JavaScript
DICOMweb

Project Overview


The DiPNG application has two parts, 1. The Dicom to PNG Converter and 2. The Medical Image Viewer. The Converter is written in Python and the Viewer is written in HTML, CSS and JavaScript. DiPNG complies with the DICOMweb standard.

Dicom to PNG Converter


The Converter is a Python module that converts a binary Dicom file to a PNG image. It contains three Python functions,
1. dicom_to_png,
2. setup_files,
3. convert_folder.
The dicom_to_png function takes two parameters dicom_file and png_file. It reads the dicom data from the dicom_file and writes that data to a png_file. setup_files checks the status of the file paths provided and passes those files as input to the main function. convert_folder converts all dicom files in a folder to png files in a destination folder.


  • # The function that checks the status of the file paths provided and passes those files as input to the main function.

  • def setup_files(dicom_file_path, png_file_path):
  • # Checking if the dicom file exists.
  • if not os.path.exists(dicom_file_path):
  • raise Exception('File "%s" does not exists' % dicom_file_path)
  • # Checking if the dicom file exists.
  • if os.path.exists(png_file_path):
  • raise Exception('File "%s" already exists' % png_file_path)

  • # Reads the dicom file.
  • dicom_file = open(dicom_file_path, 'rb')
  • # Writes the png file.
  • png_file = open(png_file_path, 'wb')

  • # Passing the files to the main function.
  • dicom_to_png(dicom_file, png_file)
  • # Closes the png file.
  • png_file.close()

Medical Image Viewer


The Medical Image Viewer part of DiPNG application is made with a custom DiPNG front end framework. Which makes the images and the overall UI display responsive on all devices.