def main(): """docstring for main""" settings = ut.options() fabric.api.env.warn_only = True for h in settings.hosts: execute(ut.get_sysmon_logs, settings = settings, hostname = h, hosts = [h])
def get_url(event, root, frame): url = entry.get() emails = [] with open(filename, 'w') as file: file.write("<body bgcolor=\"#91B5B5\"></body>") file.write('<h1>URL: ' + url + '</h1>') file.write('<h2>Emails found:</h2>') with open(filename, "a") as file: for email in re.findall(b"[\w.-]+@[\w.-]+", urllib.request.urlopen(url).read(), re.I): if not (email in emails): emails.append(email) email = email.decode('ASCII') file.write('<p>' + email + '</p>') print_in_file(url, emails) utils.options(root, frame)
def getname(event): attack = entry1.get() flag2 = False # Checks if folder of the Attack already exists for d2 in os.listdir(os.getcwd()): # Scan every directory if d2 == attack: os.chdir(attack) # Changes to directory with the name of the Attack flag2 = True if flag2 is False: # If there is no such directory os.mkdir(attack) # It creates one os.chdir(attack) # And changes to it text = 'Attack Surface.html' if not os.path.exists(text): # Checks if the file already exists file = open(text, "w") # If not, it creates one file.write("<body bgcolor=\"#91B5B5\"></body>") file.write("<h1>Attack Surface!</h1>\n") file.write("<h2>Attack name : " + attack + "</h2>\n") utils.options(root, frame)
def main(): if os.path.exists(twpc_helper.save_path): twpc_helper.save_path = options(twpc_helper.save_path) print(f"New path: {twpc_helper.save_path}") articles = [] end = file_len(twpc_helper.source_path) with open(twpc_helper.source_path, "rb") as f: for i, article in enumerate(jl_reader(f), start=1): article["contents"] = list(filter(None, article["contents"])) article["category"], article["subcategory"] = get_categories( article) # Ugly code, but significantly speeds up the process if a category is set if twpc_helper.category is not None and not article[ "category"] == twpc_helper.category: if i % twpc_helper.batch_size == 0 or i == end: if len(articles) > 0: save_as_csv(articles) articles = [] print(f"Progress: {i} / {end}.") continue article["text"] = stringify_contents(article) article["date"], article["time"] = unix_to_dt(article) article["image_url"], article[ "image_caption"] = get_image_url_and_caption(article) article["author_bio"] = get_author_bio(article) if article["title"] is None or article["title"] == "": article["title"] = np.nan if article["author"] == "": article["author"], article[ 'subtype'] = get_author_if_compilation(article) else: article["subtype"] = "standalone" discard_properties(article) articles.append(article) if i % twpc_helper.batch_size == 0 or i == end: save_as_csv(articles) articles = [] print(f"Progress: {i} / {end}.")
def get_name(event, root, old_frame): name = entry.get() old_frame.destroy() if name != 'root': user = LinuxUser(name) password = user.crack() else: root_user = LinuxRoot() password = root_user.crack() frame = Frame(root, bg='#191E19') frame.pack(expand=TRUE) var = StringVar() var.set('User\'s: %s password is: %s' % (name, password)) msg = Label(frame, textvariable=var, relief=RAISED ) msg.grid(pady=2) button = Button(frame, text='Menu', fg='#191E19', bg='#FF0000', activebackground='#FF3333', bd=3, relief=RIDGE, command=lambda: utils.options(root, frame)) button.grid(pady=2)
# Layout app.layout = html.Div([ html.Div( className="row", children=[ html.H6("Bubbles"), html.Div( className="row", children=[ html.Div( className="col s12 m6 l6", children=[ html.Label("Y Axis"), dcc.Dropdown( id="y_axis_selection", options=options(DATA_CHOICES), value=DEFAULT_Y_AXIS, ), ], ), html.Div( className="col s12 m6 l6", children=[ html.Label("Countries"), dcc.Dropdown( id="countries_selection", options=options(init_config["countries"]), value=[], multi=True, ), ],
def menu(): choice = '' images = [None, None] names = ['', ''] while (choice is not 'Q' and choice is not 'q'): print("************MENU**************") #time.sleep(1) print() choice = input(""" A: Carregar imagem B: Exibir imagem C: Salvar imagem D: Exibir negativo E: Equalizar histograma F: Transformação de Intensidade Gray G: Transformação de Potencia H: Binarização de Imagem Q: Sair Imagens no sistema: %s Opção: """ % str(names)) if choice == "Q" or choice == "q": sys.exit elif choice == "A" or choice == "a": n = 1 - options(images, names, 'Qual das imagens deseja sobrescrever?') images[n], names[n] = lab1.loadImage() elif images[0] is None and images[1] is None: print('Nenhuma imagem no sistema') print('<Pressione ENTER para continuar>') input() elif choice == "B" or choice == "b": if images[1] is None: lab1.viewImage(images[0], names[0]) elif images[0] is None: lab1.viewImage(images[1], names[1]) else: lab1.viewImages(images, names) elif choice == "C" or choice == "c": n = options(images, names, 'Qual das imagens deseja salvar?') lab1.saveImage(images[n]) elif choice == "D" or choice == "d": n = options(images, names, 'Qual das imagens será negativa?') images[n] = negative(images[n]) elif choice == "E" or choice == "e": n = options(images, names, 'Qual das imagens será equalizada?') if len(images[n].shape) < 3: images[n] = equalizeHist_gray(images[n]) else: images[n] = equalizeHist(images[n]) elif choice == "F" or choice == "f": n = options(images, names, 'Qual das imagens será transformada (gray)?') mudar = input( "Deseja mudar os intervalos e valores da transformada (s/n)? ") if mudar == 's' or mudar == 'S': a, b, alfa, beta, charlie = input( "Qual é o valor do limiar (faixa de valores) 'a' e 'b', e quais os novos valores serão atribuídos aos intervalos 1, 2 e 3? [escrever em uma linha, separado por vírgula] " ) images[n] = trans_intensidade_gray(images[n]) elif choice == "G" or choice == "g": n = options(images, names, 'Qual das imagens será transformada?') images[n] = trans_potencia(images[n]) elif choice == "H" or choice == "h": n = options(images, names, 'Qual das imagens será binarizada?') value = input('Limiar? (0 < limiar < 255) :') value = int(value) if value > 0 and value < 255: images[n] = lab1.binarizar(images[n], value) #images[n] = binarizar_gray(images[n],float(limiar)) else: print("You must only select either A,B,C,D,E,F,G,H or Q.") print("Please try again")
def menu(): choice = '' images = [None, None] names = ['', ''] while (choice is not 'Q' and choice is not 'q'): print("************MENU**************") #time.sleep(1) print() choice = input(""" A: Carregar imagem B: Exibir imagem C: Salvar imagem D: Exibir Histograms E: Calcular imagem-diferença, erro médio quadrático e PSNR F: Alterar a intensidade G: Alterar o brilho H: Fazer sub-amostragem I: Binarizar Q: Sair Imagens no sistema: %s Opção: """ % str(names)) if choice == "Q" or choice == "q": sys.exit elif choice == "A" or choice == "a": n = 1 - options(images, names, 'Qual das imagens deseja sobrescrever?') images[n], names[n] = loadImage() elif images[0] is None and images[1] is None: print('Nenhuma imagem no sistema') print('<Pressione ENTER para continuar>') input() elif choice == "B" or choice == "b": if images[1] is None: viewImage(images[0], names[0]) elif images[0] is None: viewImage(images[1], names[1]) else: viewImages(images, names) elif choice == "C" or choice == "c": n = options(images, names, 'Qual das imagens deseja salvar?') saveImage(images[n]) elif choice == "D" or choice == "d": viewHistograms(images[0]) viewHistograms(images[1]) elif choice == "E" or choice == "e": option = 'A' if images[0] is None or images[1] is None: print( 'Sao necessarias duas imagens no sistema para calcular a diferenca' ) option = input('Deseja carregar outra imagem ? A:sim B:nao :') if (option == 'A' or option == 'a') and images[0] is None: images[0], names[0] = loadImage() elif (option == 'A' or option == 'a') and images[1] is None: images[1], names[1] = loadImage() if (option == 'A' or option == 'a' ) and images[0] is not None and images[1] is not None: calImgDif(images[0], images[1]) elif choice == "F" or choice == "f": n = options(images, names, 'Qual das imagens deseja alterar a intensidade?') value = 0 print( '(Utilize valor negativo para diminuir e positivo para aumentar)' ) value = input( 'A intensidade será alterada em quanto? [-255,255] :') value = int(value) if value >= -255 and value <= 255: images[n] = itensidade(images[n], abs(value), (value > 0)) elif choice == "G" or choice == "g": n = options(images, names, 'Qual das imagens deseja alterar o brilho?') print( '(Utilize valor negativo para diminuir e positivo para aumentar)' ) value = input('O brilho será alterado em quanto? [-255,255] :') value = int(value) if value >= -255 and value <= 255: images[n] = brightness(images[n], abs(value), (value > 0)) elif choice == "H" or choice == "h": n = options(images, names, 'Qual das imagens deseja alterar a amostragem?') print( ' O valor de amostragem, aqui, representa, aproximadamente, quantos pixels serão unidos em x e y.' ) print( ' Este valor é aproximado porque as dimensoes da imagem podem não ser multiplas do valor da amostragem' ) value = input( 'A amostragem será alterado em quanto? (0 < amostragem) :') value = int(value) if value > 0: images[n] = subamostragem(images[n], value) elif choice == 'I' or choice == 'i': n = options(images, names, 'Qual das imagens deseja binarizar?') value = input('Limiar? (0 < limiar < 255) :') value = int(value) if value > 0 and value < 255: images[n] = binarizar(images[n], value) else: print("You must only select A to I or Q.") print("Please try again")
def menu(): choice = '' images = [None, None] names = ['', ''] while (choice != 'Q' and choice != 'q'): print("************MENU**************") #time.sleep(1) print() choice = input(""" A: Carregar imagem B: Exibir imagem C: Salvar imagem D: Detecção de descontinuidades e limiarização E: Transformada de Hough F: K-means Q: Sair Imagens no sistema: %s Opção: """ % str(names)) if choice == "Q" or choice == "q": sys.exit elif choice == "A" or choice == "a": n = 1 - options(images, names, 'Qual das imagens deseja sobrescrever?') images[n], names[n] = lab1.loadImage() elif images[0] is None and images[1] is None: print('Nenhuma imagem no sistema') print('<Pressione ENTER para continuar>') input() elif choice == "B" or choice == "b": if images[1] is None: lab1.viewImage(images[0], names[0]) elif images[0] is None: lab1.viewImage(images[1], names[1]) else: lab1.viewImages(images, names) elif choice == "C" or choice == "c": n = options(images, names, 'Qual das imagens deseja salvar?') lab1.saveImage(images[n]) elif choice == "D" or choice == "d": n = options( images, names, 'Qual das imagens será aplicada detecção de descontinuidades e limiarização?' ) images[n] = descontinuidade(images[n]) elif choice == "E" or choice == "e": check = False while (not check): choice = input(""" Qual tranformada aplicar? Circulos(C) ou Linhas(L): """) if choice == 'L' or choice == 'l': check = True n = options( images, names, 'Qual das imagens será aplicado a Transformada de Hough?' ) print(""" Transformada de Hough(linhas)\n""") limiar = int(input("Qual o valor do limiar?")) images[n] = houghLinhas(images[n], limiar) elif choice == 'C' or choice == 'c': check = True n = options( images, names, 'Qual das imagens será aplicado a Transformada de Hough?' ) print(""" Transformada de Hough(circulos)\n""") raioMin = int( input("Qual o valor do raio minimo? (recomendado: 1)")) raioMax = int( input( "Qual o valor do raio maximo? (recomendado: 50)")) images[n] = houghCirculos(images[n], raioMin, raioMax) else: print("Opcao invalida") elif choice == "F" or choice == "f": n = options(images, names, 'Qual das imagens será aplicado o K-Means?') check = False while (not check): choice = input(""" Deseja usar a imagem em tons de cinza? Sim(S) ou Nao(N): """) if choice == 'S' or choice == 's': check = True gray = True elif choice == 'N' or choice == 'n': check = True gray = False K = int(input("Numero de regioes: ")) images[n] = kmeans(images[n], gray, K) else: print("You must only select either A,B,C,D,E,F,G or Q.") print("Please try again")
def menu(): choice = '' images = [None , None] names = ['', ''] while(choice is not 'Q' and choice is not 'q'): print("************MENU**************") #time.sleep(1) print() choice = input(""" A: Carregar imagem B: Exibir imagem C: Salvar imagem D: Filtro de Mediana E: Exibir múltiplos filtros de mediana F: Filtro de Média G: Filtro Gaussiano H: Filtro Sobel I: Filtro Laplaciano Q: Sair Imagens no sistema: %s Opção: """ % str(names)) if choice=="Q" or choice=="q": sys.exit elif choice == "A" or choice =="a": n = 1 - options(images, names, 'Qual das imagens deseja sobrescrever?') images[n], names[n] = lab1.loadImage() elif images[0] is None and images[1] is None: print('Nenhuma imagem no sistema') print('<Pressione ENTER para continuar>') input() elif choice == "B" or choice =="b": if images[1] is None: lab1.viewImage(images[0], names[0]) elif images[0] is None: lab1.viewImage(images[1], names[1]) else: lab1.viewImages(images, names) elif choice == "C" or choice =="c": n = options(images, names, 'Qual das imagens deseja salvar?') lab1.saveImage(images[n]) elif choice=="D" or choice=="d": n = options(images, names, 'Qual das imagens será aplicado o filtro de mediana?') images[n] = calcMaskMedianaUnico(images[n]) elif choice=="E" or choice=="e": n = options(images, names, 'Qual das imagens serão aplicados vários filtros de mediana para serem exibidos??') exibirMultiplasMaskMediana(images[n]) elif choice=="F" or choice=="f": n = options(images, names, 'Qual das imagens será aplicado o filtro de Média?') images[n] = calcMaskMedia(images[n]) elif choice=="G" or choice=="g": n = options(images, names, 'Qual das imagens será aplicado o filtro Gaussiano?') images[n] = filterGaussian(images[n]) elif choice=="H" or choice=="h": n = options(images, names, 'Qual das imagens será aplicado o filtro Sobel?') images[n] = sobel(images[n]) elif choice=="I" or choice=="i": n = options(images, names, 'Qual das imagens será aplicado o filtro Laplaciano?') images[n] = laplaciano(images[n]) else: print("You must only select A to I or Q.") print("Please try again")
def menu(): choice = '' images = [None, None] names = ['', ''] while (choice is not 'Q' and choice is not 'q'): print("************MENU**************") #time.sleep(1) print() choice = input(""" A: Carregar imagem B: Exibir imagem C: Salvar imagem D: Filtro morfológico de erosão E: Filtro morfológico de dilatação F: Filtro Prewitt G: Filtro Kirsch H: Filtro de Canny I: Filtro bilateral Q: Sair Imagens no sistema: %s Opção: """ % str(names)) if choice == "Q" or choice == "q": sys.exit elif choice == "A" or choice == "a": n = 1 - options(images, names, 'Qual das imagens deseja sobrescrever?') images[n], names[n] = lab1.loadImage() elif images[0] is None and images[1] is None: print('Nenhuma imagem no sistema') print('<Pressione ENTER para continuar>') input() elif choice == "B" or choice == "b": if images[1] is None: lab1.viewImage(images[0], names[0]) elif images[0] is None: lab1.viewImage(images[1], names[1]) else: lab1.viewImages(images, names) elif choice == "C" or choice == "c": n = options(images, names, 'Qual das imagens deseja salvar?') lab1.saveImage(images[n]) elif choice == "D" or choice == "d": n = options(images, names, 'Qual das imagens será aplicado o filtro de erosão?') print("Erosão\n") mask = int( input( "Qual o tamanho da máscara? ex.: 5 - vai ser uma máscara 5x5 \n -->" )) mask = (mask, mask) tipo = -1 tipo = int( input( "Qual o formato da máscara? 0: retangular; 1: elíptica; 2:cruz. \n -->" )) images[n] = erosao(images[n], mask, tipo) elif choice == "E" or choice == "e": n = options( images, names, 'Qual das imagens será aplicado o filtro de dilatação?') print("Dilatação\n") mask = int( input( "Qual o tamanho da máscara? ex.: 5 - vai ser uma máscara 5x5 \n -->" )) mask = (mask, mask) tipo = -1 tipo = int( input( "Qual o formato da máscara? 0: retangular; 1: elíptica; 2:cruz. \n -->" )) images[n] = dilatar(images[n], mask, tipo) elif choice == "F" or choice == "f": n = options( images, names, 'Qual das imagens será aplicado o filtro de dilatação?') images[n] = prewitt(images[n]) elif choice == "G" or choice == "g": n = options( images, names, 'Qual das imagens será aplicado o filtro de dilatação?') images[n] = kirsch(images[n]) elif choice == "H" or choice == "h": n = options(images, names, 'Qual das imagens será aplicado o filtro de Canny?') images[n] = canny(images[n]) elif choice == "I" or choice == "i": n = options(images, names, 'Qual das imagens será aplicado o filtro bilateral?') images[n] = bilateral(images[n]) else: print("You must only select either A,B,C,D,E,F,G or Q.") print("Please try again")
class View(Geometry): "Phidelta view (model, view, controller design pattern)" __settings__ = settings(s=12, linewidth=2, cmap='jet') # plot settings __options__ = options('axes', 'borders', 'crossings', 'fill') # plot options # -------------------- PUBLIC SECTION ----------------------------------------- def __init__(self, phi, delta, names=None, ratio=1.): "Initialize a view object for phidelta diagrams" super().__init__(ratio=ratio) self.phi, self.delta = phidelta_std2gen(phi, delta, ratio=ratio) self.names = names self.settings = self.__settings__ self.options = self.__options__ self.figure, self.axes = None, None def plot(self, title=''): "Plot 2D data" # names not used yet ... if not self.figure: self.plot_shape(title=title) colors = 1. - np.abs(self.delta) self.axes.scatter(self.phi, self.delta, c=colors, **self.settings) plt.show() def __lshift__(self, items): # plot options/settings controller (add/update) "Activate phidelta 'plot' options or settings" if type(items) == str: items = (items, ) if type(items) in (tuple, list, set): self.add_options(items) elif type(items) == dict: self.update_settings(items) else: print("{} are not valid options / settings ...".format(items)) return def __rshift__(self, items): # plot options controller (del) "Deactivate phidelta 'plot' options" if type(items) == str: items = (items, ) if type(items) in (tuple, list, set): self.del_options(items) else: print("{} are not valid options ...".format(items)) return # -------------------- PRIVATE SECTION: OPTIONS AND SETTINGS ------------------ def add_options(self, optList): options = set(self.options) [options.add(opt) for opt in optList if opt in self.__options__] self.options = list(options) return self def del_options(self, optList): options = set(self.options) [options.discard(opt) for opt in optList] self.options = list(options) return self def update_settings(self, kwargs): # scatter options controller (add) "Set options for pyplot.scatter" if not kwargs: self.settings = self.__settings__ for k, v in kwargs.items(): if not k in self.__settings__: continue self.settings[k] = self.__settings__[k] if v == None else v return self # -------------------- PRIVATE SECTION: PLOTTING SHAPE ------------------------ def plot_shape(self, title=''): "Shows a phidelta diagram" self.figure = plt.figure() self.axes = self.figure.add_subplot(111, aspect='equal') self.set_title(title) self.set_limits() if 'axes' in self.options: self.draw_axes() if 'borders' in self.options: self.draw_borders() if 'crossings' in self.options: self.draw_crossings() if 'fill' in self.options: self.fill() def set_title(self, title=''): "Set the title of a plot (removing quotes if needed)" self.axes.set_title(remove_quoting(title)) def set_limits(self): "Set limits of a phidelta diagram" xmin, ymax, xmax, ymin = multiple_get(self.limits, self.limit_keys) self.axes.set_xlim(xmin, xmax) self.axes.set_ylim(ymin, ymax) def draw_axes(self): "Draw axes of a phidelta diagram" xmin, ymax, xmax, ymin = multiple_get(self.limits, self.limit_keys) self.axes.plot([0., 0.], [-1., 1.], color='b', zorder=1) self.axes.plot([xmin, xmax], [0., 0.], color='b', zorder=1) def draw_borders(self): "Draw borders of a phidelta diagram" X, Y = unzip2(multiple_get(self.borders, self.border_keys)) self.axes.plot(X + X[:1], Y + Y[:1], color='r', zorder=1) def draw_crossings(self): "Draw crossings of a phidelta diagram" left, top, right, bottom = multiple_get(self.borders, self.border_keys) X, Y = zip(left, right) self.axes.plot(X, Y, color='0.5', linestyle='dashed', zorder=1) X, Y = zip(top, bottom) self.axes.plot(X, Y, color='0.5', linestyle='dashed', zorder=1) def fill(self, size=160): "Fill the background of a phidelta diagram" X, Y = unzip2(multiple_get(self.borders, self.border_keys)) self.axes.fill(X + X[:1], Y + Y[:1], color='lightgrey', zorder=0)
phi, delta = model.make_grid(size=10) view = View(phi, delta) view.plot() if run['random']: phi, delta = model.random_samples(nsamples=100) view = View(phi, delta) view.plot() if run['data']: dataset = 'breast-cancer' path = "../datasets/UCI datasets/" data, labels, info = Loader(path=path).get(dataset) phi, delta, names, ratio = Statistics(data, labels, info).make(verbose=True) view = View(phi, delta, names, ratio=ratio) view.plot(title=dataset) if run['settings']: phi, delta = model.make_grid(size=10) view = View(phi, delta, ratio=2.) view << options('fill', 'crossings', 'axes') view << settings(s=14, cmap='plasma') # jet, plasma, cool, ... view.plot(title='Testing view settings and options') # -----------------------------------------------------------------------------
"published_on"] = metadata['postedDate'] or metadata['docDate'] # include anything else as State-specific extra data document["state"] = metadata # the full text text_path = os.path.join(doc_path, "document.txt") if os.path.exists(text_path): text = open(text_path).read() document["text"] = text else: print("[%s] NO TEXT ON DISK." % document_id) missing += 1 # throw it in elasticsearch print("[%i][%s] Loading into elasticsearch." % (i, document_id)) es.index(index=index, doc_type=mapping, id=document_id, body=document) i += 1 if limit and (i > int(limit)): break print("Okay, loaded %i documents into Elasticsearch." % i) print("Missing text on disk: %i" % missing) # reload the index es.indices.refresh() run(utils.options()) if (__name__ == "__main__") else None
has_bad_banner = utils.boolean_for(dict_row["USWDS Bad Banner Text"]) is_uswds_present = utils.boolean_for(dict_row["USWDS Present"]) if (has_bad_banner): bad_banner.append({ 'hostname': dict_row["Domain"], 'base_domain': dict_row["Base Domain"], 'scanned_url': dict_row["Scanned URL"] }) if (is_uswds_present): uswds_present.append({ 'hostname': dict_row["Domain"], 'base_domain': dict_row["Base Domain"], 'scanned_url': dict_row["Scanned URL"] }) # Save resulting JSON. bad_banner_data = utils.json_for(bad_banner) bad_banner_output = os.path.join(output_path, "bad_banner.json") utils.write(bad_banner_data, bad_banner_output) uswds_present_data = utils.json_for(uswds_present) uswds_present_output = os.path.join(output_path, "uswds_present.json") utils.write(uswds_present_data, uswds_present_output) if __name__ == '__main__': run(utils.options())
return bytes.decode(response.content) ##### Disk paths def meta_path_for(doc_type, agency, year, doc_id): return os.path.join(utils.data_dir(), "foiaonline/meta", doc_type, agency, year, ("%s.json" % doc_id) ) # cache .html of landing pages for records/requests/etc def cache_path_for(doc_type, agency, year, doc_id): return os.path.join(utils.data_dir(), "foiaonline/cache", doc_type, agency, year, ("%s.html" % doc_id) ) # save .json and .pdf docs (.txt's will end up there too) def data_path_for(doc_type, agency, year, doc_id, extension): return os.path.join(utils.data_dir(), "foiaonline/data", doc_type, agency, year, ("%s/%s.%s" % (doc_id, doc_type, extension)) ) run(utils.options()) if (__name__ == "__main__") else None
def menu(): choice = '' images = [None, None] names = ['', ''] while (choice is not 'Q' and choice is not 'q'): print("************MENU**************") #time.sleep(1) print() choice = input(""" A: Carregar imagem B: Exibir imagem C: Salvar imagem D: Exibir Histograms E: Calcular imagem-diferença, erro médio quadrático e PSNR F: Alterar a intensidade G: Alterar o brilho H: Fazer sub-amostragem I: Binarizar J: Exibir negativo K: Equalizar histograma L: Transformação de Intensidade Gray M: Transformação de Potencia N: Filtro de Mediana O: Exibir múltiplos filtros de mediana P: Filtro de Média R: Filtro Gaussiano S: Filtro Sobel T: Filtro Laplaciano Q: Sair Imagens no sistema: %s Opção: """ % str(names)) if choice == "Q" or choice == "q": sys.exit elif choice == "A" or choice == "a": n = 1 - options(images, names, 'Qual das imagens deseja sobrescrever?') images[n], names[n] = lab1.loadImage() elif images[0] is None and images[1] is None: print('Nenhuma imagem no sistema') print('<Pressione ENTER para continuar>') input() elif choice == "B" or choice == "b": if images[1] is None: lab1.viewImage(images[0], names[0]) elif images[0] is None: lab1.viewImage(images[1], names[1]) else: lab1.viewImages(images, names) elif choice == "C" or choice == "c": n = options(images, names, 'Qual das imagens deseja salvar?') lab1.saveImage(images[n]) elif choice == "D" or choice == "d": lab1.viewHistograms(images[0]) lab1.viewHistograms(images[1]) elif choice == "E" or choice == "e": option = 'A' if images[0] is None or images[1] is None: print( 'Sao necessarias duas imagens no sistema para calcular a diferenca' ) option = input('Deseja carregar outra imagem ? A:sim B:nao :') if (option == 'A' or option == 'a') and images[0] is None: images[0], names[0] = lab1.loadImage() elif (option == 'A' or option == 'a') and images[1] is None: images[1], names[1] = lab1.loadImage() if (option == 'A' or option == 'a' ) and images[0] is not None and images[1] is not None: lab1.calImgDif(images[0], images[1]) elif choice == "F" or choice == "f": n = options(images, names, 'Qual das imagens deseja alterar a intensidade?') value = 0 print( '(Utilize valor negativo para diminuir e positivo para aumentar)' ) value = input( 'A intensidade será alterada em quanto? [-255,255] :') value = int(value) if value >= -255 and value <= 255: images[n] = lab1.itensidade(images[n], abs(value), (value > 0)) elif choice == "G" or choice == "g": n = options(images, names, 'Qual das imagens deseja alterar o brilho?') print( '(Utilize valor negativo para diminuir e positivo para aumentar)' ) value = input('O brilho será alterado em quanto? [-255,255] :') value = int(value) if value >= -255 and value <= 255: images[n] = lab1.brightness(images[n], abs(value), (value > 0)) elif choice == "H" or choice == "h": n = options(images, names, 'Qual das imagens deseja alterar a amostragem?') print( ' O valor de amostragem, aqui, representa, aproximadamente, quantos pixels serão unidos em x e y.' ) print( ' Este valor é aproximado porque as dimensoes da imagem podem não ser multiplas do valor da amostragem' ) value = input( 'A amostragem será alterado em quanto? (0 < amostragem) :') value = int(value) if value > 0: images[n] = lab1.subamostragem(images[n], value) elif choice == 'I' or choice == 'i': n = options(images, names, 'Qual das imagens deseja alterar o limiar?') value = input('Limiar? (0 < limiar < 255) :') value = int(value) if value > 0 and value < 255: images[n] = lab1.binarizar(images[n], value) elif choice == "J" or choice == "j": n = options(images, names, 'Qual das imagens será negativa?') images[n] = lab2.negative(images[n]) elif choice == "K" or choice == "k": n = options(images, names, 'Qual das imagens será equalizada?') if len(images[n].shape) < 3: images[n] = lab2.equalizeHist_gray(images[n]) else: images[n] = lab2.equalizeHist(images[n]) elif choice == "L" or choice == "l": n = options(images, names, 'Qual das imagens será transformada (gray)?') mudar = input( "Deseja mudar os intervalos e valores da transformada (s/n)? ") if mudar == 's' or mudar == 'S': a, b, alfa, beta, charlie = input( "Qual é o valor do limiar (faixa de valores) 'a' e 'b', e quais os novos valores serão atribuídos aos intervalos 1, 2 e 3? [escrever em uma linha, separado por vírgula] " ) images[n] = lab2.trans_intensidade_gray(images[n]) elif choice == "M" or choice == "m": n = options(images, names, 'Qual das imagens será transformada?') images[n] = lab2.trans_potencia(images[n]) elif choice == "N" or choice == "n": n = options(images, names, 'Qual das imagens será aplicado o filtro de mediana?') images[n] = lab3.calcMaskMedianaUnico(images[n]) elif choice == "O" or choice == "o": n = options( images, names, 'Qual das imagens serão aplicados vários filtros de mediana para serem exibidos??' ) lab3.exibirMultiplasMaskMediana(images[n]) elif choice == "P" or choice == "p": n = options(images, names, 'Qual das imagens será aplicado o filtro de Média?') images[n] = lab3.calcMaskMedia(images[n]) elif choice == "R" or choice == "r": n = options(images, names, 'Qual das imagens será aplicado o filtro Gaussiano?') images[n] = lab3.filterGaussian(images[n]) elif choice == "S" or choice == "s": n = options(images, names, 'Qual das imagens será aplicado o filtro Sobel?') images[n] = lab3.sobel(images[n]) elif choice == "T" or choice == "t": n = options(images, names, 'Qual das imagens será aplicado o filtro Laplaciano?') images[n] = lab3.laplaciano(images[n]) else: print("You must only select A to T.") print("Please try again")