diff --git a/utils.py b/utils.py index 693c8470aca12ca0829f1de967dcad4a5c2b8b04..493452c488183924e71c265d9488ddde8b988cda 100644 --- a/utils.py +++ b/utils.py @@ -303,7 +303,29 @@ def saveImage(img, fullResultPath, figSize): plt.savefig(fullResultPath) plt.close() - +# method to visualize image as well as the prediction after tubule dilation as well as its overlay +def overlayVisualization(img, lbl, imgStr, lblStr): + # remove tubuli border prepare visualization + lbl[lbl==7] = 0 + customColorMap = mpl.colors.ListedColormap(['black', 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'brown']) + lblMasked = np.ma.masked_where(lbl == 0, lbl) + sizeShift = (640-516)//2 + + plt.figure(figsize=(20,8)) + plt.subplot(131) + plt.imshow(img[sizeShift:sizeShift+516, sizeShift:sizeShift+516, :]) + plt.axis('off') + plt.title(imgStr) + plt.subplot(132) + plt.imshow(lbl, cmap=customColorMap, vmin = 0, vmax = 7) + plt.axis('off') + plt.title(lblStr) + plt.subplot(133) + plt.imshow(img[sizeShift:sizeShift+516, sizeShift:sizeShift+516, :]) + plt.imshow(lblMasked, cmap=customColorMap, vmin = 0, vmax = 7, alpha=0.45) + plt.axis('off') + plt.title('Overlay') + plt.subplots_adjust(wspace=0, hspace=0) def getCrossValSplits(dataIDX, amountFolds, foldNo, setting): """ @@ -698,4 +720,4 @@ def getChannelSmootingConvLayer(channels, kernel_size=5, sigma=1.5): if __name__ == '__main__': - print() \ No newline at end of file + print()