Posted by
Cardone, Giovanni on
Oct 08, 2019; 3:05pm
URL: http://imagej.273.s1.nabble.com/Histogram-Matching-python-script-attached-questions-remain-tp5022497p5022498.html
Hi Rainer,
orobably I can help with issue #1.
The error reported is not harmful, just annoying. The way I got rid of it was to modify the content of the file ImageJ.cfg
This file is located inside the Fiji.app directory. If you don't see it, go to the menu Edit/Options/Memory&Threads, change the memory size and press Ok. The file should show up.
Open the file with a text editor and add to the line of parameters the following
-Dpython.console.encoding=UTF-8
Just to give an idea, in my case the content of the file looks like
=====================================================
.
jre\bin\javaw.exe
-Dpython.console.encoding=UTF-8 -Xmx26000m -cp ij.jar ij.ImageJ
=====================================================
I hope that helps,
Giovanni
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of Rainer M. Engel
Sent: Dienstag, 8. Oktober 2019 13:40
To:
[hidden email]
Subject: ***SPAM*** [MSX] Histogram Matching | python script attached, questions remain
Hey everyone..
I'm typically working with another software, where histogram matching is easy available. Recently I stumbled upon an thread on stack overflow on this topic with ImageJ
https://stackoverflow.com/questions/25085871/match-histogram-imagejSince I wanted to create a "script plugin" which I can call from a macro, I finally chose python, because it was easier to find examples helping me out.
I used these two images..
"
https://juliahartel.files.wordpress.com/2013/07/kornfeld-in-goldener-abendsonne.jpg"
"
https://naturfotografen-forum.de/data/o/142/713934/image::Frank_Steinmann_auwald_rheinaue_wald.jpg"
Hoping the indentation is preserved!
#PYTHON-CODE---------------------------------------------------
from fiji.util.gui import GenericDialogPlus import ij.IJ from histogram2 import HistogramMatcher
# Create an instance of GenericDialogPlus gui = GenericDialogPlus("histogram matching..")
# Add possibility to choose some images already opened in Fiji gui.addImageChoice("target image","image1") gui.addImageChoice("reference image","image2")
gui.showDialog()
# Recover the inputs in order of "appearance"
if gui.wasOKed():
ImpImage1 = gui.getNextImage() # This method directly returns the ImagePlus object
ImpImage2 = gui.getNextImage()
ip1 = ImpImage1.getProcessor()
ip2 = ImpImage2.getProcessor()
hist1 = ip1.getHistogram()
hist2 = ip2.getHistogram()
matcher = HistogramMatcher()
newHist = matcher.matchHistograms(hist1, hist2)
ip1.applyTable(newHist)
ImpImage1.setProcessor(ip1)
ImpImage1.show()
ImpImage2.show()
#PYTHON-CODE---------------------------------------------------
Questions:
1) This works interactively, but on first execution I get an error:
[INFO] Reading available sites from
https://imagej.net/console: Failed to install '':
java.nio.charset.UnsupportedCharsetException: cp0.
What can I do about this char-error?
2) I hoped calling it from a macro would work with ease.. but I do not know how or where to put the script.
run("script:histogram-match.py", "target=[image Frank_Steinmann_auwald_rheinaue_wald.jpg]
reference=kornfeld-in-goldener-abendsonne.jpg");
With the above, I get an file.io error.
<Error: java.io.FileNotFoundException:
http://wsr.imagej.net/download/Examples/Python/script:G:ImageJ_hist-matchhistogram-match.py>
in line 1:
var ; initializeSciJavaParameters ( ) ; run ( "script:G:ImageJ_hist-matchhistogram-match.py" , "target=[image Frank_Ste...
3) Can someone point me to python examples of a script, which differentiates between image types? What the provided script needs is a fork for RGB images (Split Channels, working on them separately and merging them later on again). This creates very good results. One would only need to tiny smooth the correction curve, to reduce artefacts (especially if i.e. "kornfeld" is the target image). Currently I don't know if this is possible with "histogram2".
Thank you very much, for any direction or help..
Kind regards,
Rainer
--
Rainer M. Engel
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html