Use centre slice in the 3D case

parent cf76522f
# Author: Ghislain Antony Vaillant <g.vaillant@imperial.ac.uk>
from __future__ import division
from argparse import ArgumentParser
from nibabel import load
from PIL import Image
......@@ -11,6 +13,7 @@ parser.add_argument('thumbnail', help='Output thumbnail')
parsed = parser.parse_args()
image = load(parsed.inputfile).get_data()
image = Image.fromarray(image[:, :, 0] if image.ndim == 3 else image)
image = Image.fromarray(image[:, :, image.shape[2]//2] if image.ndim == 3
else image)
image = image.resize([128, 128])
image.save(parsed.thumbnail)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment