1,30d0 < # slight modifications from < # https://github.com/InsightSoftwareConsortium/ITKColorNormalization/blob/master/examples/ITKColorNormalization.ipynb < # a couple of functions for my environment, ie JRS = True < < JRS = True < < def view(itk_image, title='', x=20, y=10): < """ arg itk_image from itk.imread(input_image_filename, PixelType); < convert to np array, use matplotlib to plot as usual < """ < < # assumes 'img_path' a .png, .jpg, .tiff, ... < import numpy as np < import matplotlib.pyplot as plt < img = np.array(itk_image) < print(f' view:: img.shape={img.shape}, img.dtype={img.dtype}') < imgplot = plt.imshow(img) < plt.title(title) < fig = plt.gcf() < move_fig(fig,x,y) < plt.show() < < import matplotlib as mp < def move_fig(f, x, y): < """ Move figure's upper left corner to (x, y), pixel units """ < backend = mp.get_backend() < assert backend == "TkAgg", "unable get get TkAgg' as matplotlib backend" < f.canvas.manager.window.wm_geometry(f"+{x}+{y}") < < # below ITK example of color normalization 36,40c6,7 < import os < #?? !{sys.executable} -m pip install itk-spcn < os.system("python3 -m pip install itk-spcn") < #?? !{sys.executable} -m pip install itkwidgets < os.system("python3 -m pip install itkwidgets") --- > !{sys.executable} -m pip install itk-spcn > !{sys.executable} -m pip install itkwidgets 49,50c16 < if not JRS: < from itkwidgets import view --- > from itkwidgets import view 54,62c20 < BCH = True # use Boston Children's Hospital test image < if JRS: < if BCH: < input_image_filename = 'Test_1_0810.png' # typical BCH (under-stained) data < else: < input_image_filename = 'Easy1.png' < else: < input_image_filename = 'Easy1.png' < --- > input_image_filename = 'Easy1.png' 82,86d39 < < # view inputs before attempted color normalization < view(input_image) < view(reference_image) <