Closed SahPet closed 3 years ago
I am glad this tool may be useful for medical applications. So far, I have considered batch processing from the command line, which was supposed to work when providing the source directory as follows:
color-matcher -s './tests/data/' -r './tests/data/scotland_plain.png'
However, I figured that each output file gets overriden due to identical filename creation. I fixed this issue in v0.3.2, which is now available via pip install color-matcher==0.3.2
Similar to the Jupyter notebook example, you can alternatively use the API to iterate through your image stack via a single loop like the one below:
from color_matcher import ColorMatcher
from color_matcher.io_handler import load_img_file, save_img_file, FILE_EXTS
from color_matcher.normalizer import Normalizer
import os
img_ref = load_img_file('./tests/data/scotland_plain.png')
src_path = '.'
filenames = [os.path.join(src_path, f) for f in os.listdir(src_path)
if f.lower().endswith(FILE_EXTS)]
for i, fname in enumerate(filenames):
img_src = load_img_file(fname)
obj = ColorMatcher(src=img_src, ref=img_ref, method='mkl')
img_res = obj.main()
img_res = Normalizer(img_res).uint8_norm()
save_img_file(img_res, os.path.join(os.path.dirname(fname), str(i)+'.png'))
Let me know whether this helps or if you still encounter issues.
Best, Chris
Thank you so much, Chris! I'll try it soon. Tried photoshops "match color" function, and I think color-matcher did a better job.
Thank you so much, It works perfectly! (I used it for own personal small software for my scansions of ancient books, which had to be normalized)
Glad, it works on your side!
I've just discovered color-matcher and find it potentially very useful for preprocessing histopathological datasets for deep learning. I can't, however, find a way to use it in batch mode - that is - is there any way to load more than one source image and/or more than one target image to process larger image datasets in batch?