{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MergeAdjacentImages Notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook contains a few examples of how to use the `MergeAdjacentImages` application from **TubeTK**. First, we will include Python's `os` package as well as `ITK` (Python wrapping). We also set the TubeTK build directory variable `TUBETK_BUILD_DIR`:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If ITK is not installed in your python environment, you need to define the environment variable `ITK_BUILD_DIR` that contains the path to where ITK was built." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We need to find the directory in which TubeTK was build. This is required to find the path to the testing data, and may be also required to find the TubeTK library paths if your python environment does not include it.\n", "The environment variable `TubeTK_BUILD_DIR` needs to be defined." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import sys\n", "import numpy" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import itk\n", "from itk import TubeTK as ttk\n", "from itkwidgets import view" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "from matplotlib import cm\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we load the first input image and show it's origin, spacing, etc.:" ] }, { "cell_type": "code", "execution_count": 101, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Origin:\n", "itkPointD2 ([200, 200])\n", "Spacing:\n", "itkVectorD2 ([2, 2])\n" ] } ], "source": [ "ImageType=itk.Image[itk.F,2]\n", "\n", "input_image1 = \"Data\\ES0015_Large.mha\"\n", "reader0 = itk.ImageFileReader[ImageType].New(FileName=input_image1)\n", "reader0.Update()\n", "\n", "resampler0 = ttk.ResampleImage[itk.F,2].New(Input=reader0.GetOutput(), ResampleFactor=(0.5,0.5))\n", "resampler0.Update()\n", "im0 = resampler0.GetOutput()\n", "\n", "print(\"Origin:\")\n", "print(im0.GetOrigin())\n", "print(\"Spacing:\")\n", "print(im0.GetSpacing())" ] }, { "cell_type": "code", "execution_count": 137, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "97cca19f53c14a96ad6c540f50d38c93", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=