Match histogram - ImageJ

自古美人都是妖i 提交于 2019-12-24 05:25:21

问题


Given two ImagePlus or BufferedImages (I don't care) how can I match the histogram of the first to the second one?

By matching I mean:

Matching the cumulative distribution function (CDF) of one image to the CDF of the other.


回答1:


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", "");


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!