Adjust brightness and colors of multiple pictures to match or approximate a reference picture

Greetings,

Is it possible with Fiji to make the necessary adjustments to multiple pictures in order to match, or approximate as best as possible, the brightness/contrast/colors of a different (reference) picture region or selected spots?

Different adjustments in pictures B,C,D,E,F (180 pics in total) are required in order to look similar with picture A (reference pic). Having as reference the colors/brightness of the piece of steel shown at left side, I’m trying to apply adjustments on the rest pictures to have a similar optical result in every picture, by minimizing the color/brightness difference of each picture with the reference picture.

This problem was created to the camera due to the temperature increase during an experiment. Is there a solution to this case with Fiji?

Thanks in advance.

Hi @vasos047,

Given the wide range of under- and overexposure, the jpeg format with its compression artifacts, and a camera that has (un)predictable striping near the points of interest, you will have a hard time.

Having said that, you can convert your image Image>Mode>RGB Stack, then of each channel get the histogram and of all other images, perform a histogram stretching or compression.

Of course, you only select that part of the picture that is of interest for your scientific question to generate a histogram of.

After that, reconvert to RGB colour image and save. Rinse and repeat for every target image. Macros come in handy here, of course. Have a look at this thread to see how to stretch and compress the pixel value range(s).

Don’t be disappointed by the results, as what isn’t there won’t appear magically. But then, you asked for best approximation.

1 Like

Implementation code:

close("*");
do{
	indir=getDirectory("Where is your input folder");
	if(!File.exists(indir+"reference.jpeg"))
		waitForUser("Cannot find the reference.jpeg image. Please rename and try again");
}while(!File.exists(indir+"reference.jpeg"));
open(indir+"reference.jpeg");
refImageID=getImageID();
refImgPath=getDirectory("image");
mins = newArray(3);
maxs = newArray(3);
ranges = newArray(3);
fileList=getFileList(indir);

selectImage(refImageID);
run("RGB Stack");
makeRectangle(7, 105, 44, 60);
for(i=0;i<3;i++){
	selectImage(refImageID);
	setSlice(i+1);
	mins[i]=getValue("Min");maxs[i]=getValue("Max");ranges[i]=maxs[i]-mins[i];
}
close();

for(j=0;j<fileList.length;j++){
	if(fileList[j]!="reference.jpeg" &&endsWith(fileList[j],".jpeg")){
		open(indir+fileList[j]);
		inim=getImageID();
		run("RGB Stack");
		run("Select All");
		run("Duplicate...", "title=16bit.jpeg duplicate");
		dupImgID=getImageID();
		selectImage(inim);
		imName=getTitle();
		rename("ref "+imName);
		run("RGB Color");
		selectImage(dupImgID);
		run("16-bit");//on duplicate
		rename("16 bit "+imName);
		
		for(i=0;i<3;i++){
			setSlice(i+1);
			makeRectangle(7, 105, 44, 60);
			oldMin=getValue("Min");oldMax=getValue("Max");range=oldMax-oldMin;
			run("Select All");
			
			//slide values back to origin
			run("Subtract...", "value="+oldMin+" slice");
			//adjust range to reference
			rangeMultiplier=ranges[i]/range;
			run("Multiply...", "value="+rangeMultiplier+" slice");
			//slide values to reference
			run("Add...", "value="+mins[i]+" slice");
		}
		run("8-bit");
		run("RGB Color");
		rename("improved "+imName);
	}
}
open(indir+"reference.jpeg");

run("Tile");

Open all into a stack.
Split channels.
Float the Stack (a version in http://microscopynotes.com/imagej/macros/useful_collection_v100.txt )
adjust contrast of each.
remerge as RGB

Or merge as composite, then adjust contrast of each, then convert to RGB.