Wednesday, March 20, 2019

ITK "In place" filtering

a true "in-place" filter overwrites each pixel of the
input buffer with the resultant output pixel value and then passes the
input buffer as its output. All filters capable of this should inherit
from itk::InPlaceImageFilter (if you find one that doesn't, please let
us know). You to turn on/off this functionality eg.
filter->InPlaceOn(), filter->InPlaceOff().

The itk::MeanImageFilter does not inherit from
itk::InPlaceImageFilter, the reason being it is a neighbourhood
operation; neighbourhood operations *cannot* be run in-place (the
output for one pixel may be used as the input for another pixel!).
 
https://itk.org/pipermail/insight-users/2010-October/038501.html 

Tuesday, March 19, 2019

ImageJ/FIJI match histogram

https://stackoverflow.com/questions/25085871/match-histogram-imagej

You can use the HistogramMatcher class included in Fiji (in its sub-project CorrectBleach).
Here is an example Beanshell script (you can run it via the Script Editor in Fiji):
import ij.IJ;
import histogram2.HistogramMatcher;

// get first image
imp1 = IJ.openImage("http://imagej.nih.gov/ij/images/bridge.gif");
// get second image
imp2 = IJ.openImage("http://imagej.nih.gov/ij/images/boats.gif");

ip1 = imp1.getProcessor();
ip2 = imp2.getProcessor();

hist1 = ip1.getHistogram();
hist2 = ip2.getHistogram();

matcher = new HistogramMatcher();
newHist = matcher.matchHistograms(hist1, hist2);

ip1.applyTable(newHist);
imp1.setProcessor(ip1);

imp1.show();
imp2.show();

// show the histograms of both images
IJ.run(imp1, "Histogram", "");
IJ.run(imp2, "Histogram", "");