H&E Histology Color Normalization Instructions
Color normalization using color_normalize.m
Process
colorassign_manual.m train_classifier.m color_classify.m color-normalize-m
Overview
Given an RGB image, produce a normalized histological image based on a classified map of said image and a target colors for tissue structures.
Inputs
rgb - A multidimensional array of size [MxNx3] where M and N represent the height and width of the image respectively. The third dimension of the data represents each color value (RGB). Generally this image will be the full size image from which a selection was used to train the classifier in the previous steps.
target - A 4x3 matrix of HSV values that are the normalization goal for the final image. Each row represents a single HSV value for a single structure. The order of the colors is important. The first row represents the hue, saturation, and value for the lumen structures. The second row represents nuclei. The third represents stroma, and the fourth represents cytoplasm. A target is provided which has colors chosen by researchers based on experiential preference.
0.848900926416069 0.0152811265389302 0.981439614567708
0.696789111196302 0.545814716909013 0.691547936778282
0.812964302784579 0.274613859934338 0.865239486779509
0.753346080148581 0.350023525851577 0.818282805674125
classified - A classified image of the same size and shape as rgb in which each pixel has been classified as the appropriate tissue structure based on the results of color_classify.m.
Outputs
An RGB image matching the structure of the input rgb but that has been color normalized. This can then be written to a file or stored for later processing.
Explanation
Color normalization is achieved by finding a vector between the original color values and the target color values on a structure by structure basis.
Using the classifier, each color pixel in the original image is separated. The average color of the like structures is determined and a vector is created between this average color and the target color for that structure. The vector is then used to shift all the similar structures closer to the target color. The program then does this calculation and shift for lumen, nuclei, stroma, and then cytoplasm.
The result is that each pixel in the image has been shifted closer to the target color for its matching tissue structure. The result can then be saved using imwrite.
Free Parameters
None
Example Usage
>> sampleImage = imread('/path/to/histology/sample_image.tif')
>> fullImage = imread('/path/to/histology/full_image.tif')
>> [structureMap, lumen, nuclei, stroma, cytoplasm] = colorassign_manual(loadedImage)
>> classifier = train_classifier(loadedImage, structureMap, lumen, nuclei, stroma, cytoplasm)
>> classified_image = color_classify(fullImage, classifier)
>> load(‘target.mat’)
>> normalizedImage = color_normalize(fullImage, target, classified)
>> imwrite(normalizedImage, ‘/path/to/output/normalized.tif’)
Timing
When processing a 1mm2 sample image of 2000x2000 pixels on a 2Ghz Intel i7 processor running with 8GB RAM, this function took less than 3 seconds to complete.