Why dose not work "RGBtoLab()" in Python (Jython)

Background

Hi everyone. I am Daniel.

I am a new user of ImageJ, which is necessary for my data analysis.

I want to do “Color Threshold” in Python(Jython) but there is no code written in Python, so I decided to write in Python.

This is my last post

The problem ・ error message

I could implement and translate “ColoThreshold” written in ImageJMacro in Python, but when I try the “ColoThreshold” to make Python definition(like that def hoge():) ,
the error occurs.
AttributeError: 'function' object has no attribute 'RGBtoLab

I could not fix it.

Sample image and/or code

The base code which I want to translate to Python

// Color Thresholder 2.0.0-rc-69/1.52i
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
call("ij.plugin.frame.ColorThresholder.RGBtoLab");
run("RGB Stack");
run("Convert Stack to Images");
selectWindow("Red");
rename("0");
selectWindow("Green");
rename("1");
selectWindow("Blue");
rename("2");
min[0]=0;
max[0]=255;
filter[0]="pass";
min[1]=111;
max[1]=141;
filter[1]="pass";
min[2]=142;
max[2]=171;
filter[2]="pass";
for (i=0;i<3;i++){
  selectWindow(""+i);
  setThreshold(min[i], max[i]);
  run("Convert to Mask");
  if (filter[i]=="stop")  run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");

selectWindow("Result of 0");
selectWindow("Result of Result of 0");

Dose not using definition (It work)

from ij import IJ
from ij import ImagePlus
from ij.plugin.frame import ColorThresholder
from ij.process import ImageProcessor
from ij.plugin import ImageCalculator


# Color ThresholdのマクロをJythonに翻訳するよ~
PicPath = "C:\Users\For  Programming\Documents\img016_tru.jpg"


imp = IJ.openImage(PicPath)
imp.show()
ImageTitle = imp.getTitle()

LabThresold_List =[[80 , 255] , [115 , 145] , [145 , 175]]
Filt_List = ["pass" , "pass" , "pass"] # https://imagej.nih.gov/ij/docs/guide/146-28.html Color Thresholdの"pass"の項目、よく分らん

# Color Thresholdの仕様で、開いている画像でないと作用しない。
#IJ.run(imp, "Color Threshold...", "");
ColorThresholder.RGBtoLab() # このvoidには変数が必要無い。この関数の仕様で多分、1枚しかできない。 imp = Color Thresholder の方が良い気がするけど仕様が分らん

IJ.run(imp, "RGB Stack", "")
IJ.run("Stack to Images", "") 

IJ.selectWindow("Red")
IJ.run('Rename...', 'title=0') #title=hoge =(equal)の間にスペースを入れてならない。
imp0 = IJ.getImage()
    
IJ.selectWindow("Green")
IJ.run('Rename...', 'title=1')
imp1 = IJ.getImage()

IJ.selectWindow("Blue")
IJ.run('Rename...', 'title=2')
imp2 = IJ.getImage()
            
for i in range(3):


    WindowTitle = str(i)
    MinValue = float(LabThresold_List[i][0])
    MaxValue = float(LabThresold_List[i][1])
 
    IJ.selectWindow(WindowTitle)
    IJ.setThreshold(MinValue,MaxValue)
    IJ.run(IJ.getImage(), "Convert to Mask", "")


    if Filt_List[i] == "stop":
        ImageProcessor.invert()
    

    
        
imp3 = ImageCalculator.run(imp0, imp1, "and create")
imp4 = ImageCalculator.run(imp3,imp2, "and create")

imp3.show()
imp4.show()
ResultTitle = imp4.getTitle()
IJ.selectWindow(ResultTitle)
imp4.setTitle(ImageTitle)

using definition (IT DOESN’T WORK)

from ij import IJ
from ij import ImagePlus
from ij.plugin.frame import ColorThresholder
from ij.process import ImageProcessor
from ij.plugin import ImageCalculator

def ColorThresholder(PICPATH , L_min , L_max , a_min , a_max , b_min , b_max):
    
    imp = IJ.openImage(PICPATH)
    imp.show()
    ImageTitle = imp.getTitle()

    LabThresold_List =[[L_min , L_max] , [a_min , a_max] , [b_min , b_max]]
    Filt_List = ["pass" , "pass" , "pass"]

    ColorThresholder.RGBtoLab()

    IJ.run(imp, "RGB Stack", "")
    IJ.run("Stack to Images", "")

    IJ.selectWindow("Red")
    IJ.run('Rename...', 'title=0') #title=hoge =(equal)の間にスペースを入れてならない。
    imp0 = IJ.getImage()
    
    IJ.selectWindow("Green")
    IJ.run('Rename...', 'title=1')
    imp1 = IJ.getImage()

    IJ.selectWindow("Blue")
    IJ.run('Rename...', 'title=2')
    imp2 = IJ.getImage()

    for i in range(3):

        WindowTitle = str(i)
        MinValue = float(LabThresold_List[i][0])
        MaxValue = float(LabThresold_List[i][1])
 
        IJ.selectWindow(WindowTitle)
        IJ.setThreshold(MinValue,MaxValue)
        IJ.run(IJ.getImage(), "Convert to Mask", "")


        if Filt_List[i] == "stop":
            ImageProcessor.invert()

    imp3 = ImageCalculator.run(imp0, imp1, "and create")
    imp4 = ImageCalculator.run(imp3,imp2, "and create")

    imp3.show()
    imp4.show()
    ResultTitle = imp4.getTitle()
    IJ.selectWindow(ResultTitle)
    imp4.setTitle(ImageTitle)




PicPath = "C:\Users\For  Programming\Documents\img016_tru.jpg"
ColorThresholder(PicPath,80,255,115,145,145,175)

If my English is difficult to understand, please tell me that. I rewrite about this.

I made a very stupid mistake.
It seems that the error occurs because the name of the function I defined matches the name of “RGBtoLab”.
If I rename the function I defined to something like “MakeColor Threshold”, it works.