def findHvalue(_rawImageFile="E:\workspace\jinyoung\CancerImageAnalyzer\img\BF_position020100_time0001.tif"):
    _outputPath = '/ppimg'+datetime.datetime.today().strftime('%y%m%d%H%M')+'/'
    rawImgFloat = cia.loadRawImage(_rawImageFile)
    filteredImg1st = cia.execGaussianFiltering(rawImgFloat)

    for hVal in np.arange(0.1,1.0,0.1):
        dilatedImg = cia.execMorphologicalDilation(filteredImg1st,h=hVal)
        cia.savePreprocessingImage(dilatedImg,outputPath=_outputPath,h=hVal)
def findThresholdValue(_ppImageFile="E:\workspace\jinyoung\CancerImageAnalyzer\img\ppimg1601101615\BF_position020100_time0001hVal0.4.png"):
    _thOutputPath = '/thimg'+datetime.datetime.today().strftime('%y%m%d%H%M')+'/'
    ppImageFileName = os.path.basename(_ppImageFile)
    ppImageFilePath = os.path.dirname(_ppImageFile)

    biImageFilePath = ppImageFilePath + _thOutputPath

    ppImg = cia.loadRawImage(_ppImageFile)

    for thVal in np.arange(0.1,1.0,0.1):
        filledImg = cia.convertBinaryImage(ppImg,threshold=thVal)
        if not os.path.exists(biImageFilePath):
            os.mkdir(biImageFilePath)
        biImageFileName = ppImageFileName[:ppImageFileName.rfind('.')]+'thVal'+str(thVal)+'.png'
        imsave(biImageFilePath+biImageFileName, filledImg)
def startProcess(currentDir = "E:/workspace/jinyoung/img/expr1"):

    resArr = []
    for i in os.listdir(currentDir):
        i = currentDir + '/'+i
        if os.path.isdir(i):
            resArrSub = []
            for j in os.listdir(i):
                j = i + '/' + j
                res = cia.testCancerAnalyzer(os.path.abspath(j))
                resArrSub.append(res)
            resArr.append(resArrSub)

    return resArr
def findRemSmObjValue(_biImageFile="E:/workspace/jinyoung/CancerImageAnalyzer/img/ppimg1601101508/thimg1601101511/BF_position020100_time0001hVal0.4thVal0.9.png"):
    _remSmObjOutputPath = '/remSmObjImg'+datetime.datetime.today().strftime('%y%m%d%H%M')+'/'
    remSmObjImageFileName = os.path.basename(_biImageFile)
    biImageFilePath = os.path.dirname(_biImageFile)

    reSmObjImageFilePath = biImageFilePath + _remSmObjOutputPath

    biImg = imread(_biImageFile)
    biImgRsize = biImg.shape[0] * 0.1
    biImgCsize = biImg.shape[1] * 0.1
    biImg = biImg[biImgRsize:-biImgRsize, biImgCsize:-biImgCsize]
    biImg = ndimage.binary_fill_holes(biImg)
    for smObjVal in np.arange(0,100000,10000):
        filledImg = cia.removeSmallObject(biImg, minSize=smObjVal)
        if not os.path.exists(reSmObjImageFilePath):
            os.mkdir(reSmObjImageFilePath)
        biImageFileName = remSmObjImageFileName[:remSmObjImageFileName.rfind('.')]+'smObjVal'+str(smObjVal)+'.png'
        imsave(reSmObjImageFilePath+biImageFileName, filledImg)