def CNNSeed(img, TobImg, BlockSize, FileName): BlockInfo = [0 for n in range(BlockSize)] for i in range(0, len(BlockSize)): print(str(BlockSize) + "\t:") OutImg = [[0 for n in ragne(len(TobImg[0]))] for n in range(TobImg)] for p in range(0, len(TobImg)): for q in range(0, len(TobImg[p])): if TobImg[p][q] == i: OutImg[p][q] = img[p][q] Pretreatment.FigurePrint(OutImg, kind) InpInt = Init.IntInput(str(BlockSize) + "\t:" , "1", "3", "int") if InpInt == 1: BlockInfo[i] = 1 elif InpInt == 2: BlockInfo[i] = 2 elif InpInt == 3: BlockInfo[i] = 3 BuildFile("Histogram") File = open("Histogram", "a")
def HandSeed(Tobimg, img, Surround): Upground = set() Background = set() for Kase in range(0, 2): Owari = False while 1: print( "\nInput the location you choice as '[i1, j1] [i2, j2]'. \nAfter choose, close the figure and press Enter to continue." ) if Kase == 0: print("Upground Set: ") elif Kase == 1: print("Background Set: ") #Print the figure if Surround == "Nor": Pretreatment.FigurePrint(img, 2) else: pass #Pretreatment InpStr = input() RemStr1 = "" RemStr2 = "" Str2Int = False Error = False kind = 0 #Get string for i in range(0, len(InpStr)): #Partial if InpStr[i] == "[": kind = 1 continue if InpStr[i] == ",": kind = 2 continue if InpStr[i] == "]": kind = 0 Str2Int = True if kind == 1 and Str2Int == False: RemStr1 += InpStr[i] if kind == 2 and Str2Int == False: RemStr2 += InpStr[i] if Str2Int == True: Int1 = 0 Int2 = 0 #print([RemStr1,RemStr2]) try: Int1 = int(RemStr2) Int2 = int(RemStr1) except: print("Input Error, Please input points again") Error = True break #print(Tobimg[Int1][Int2]) try: if Kase == 0: Upground.add(Tobimg[Int1][Int2]) if Kase == 1: Background.add(Tobimg[Int1][Int2]) except: print("Input Error, Location exceed") RemStr1 = "" RemStr2 = "" Str2Int = False continue if Error == True: continue else: if Kase == 0: if len(Upground) == 0: print("You must input at least 1 node!") continue else: Owari = True elif Kase == 1: if len(Background) == 0: print("You must input at least 1 node!") continue else: Owari = True if Owari == True: break else: continue return Upground, Background