Skip to content

Tag: python

cvtcolor in Cv2 – no attribute

I’m writing a program to collect a series of images from a USB microscope and generate an average as a way of denoising. I’m having to convert the image into a numpy array, sum the pixels then divide before converting back to an image. Somewhere along the line the channels get mixed so my output i…

Python unittest not recognizing tests

I’m trying to learn how to use the unittest framework in python. I keep getting the message below when I run my file containing the tests. I’ve searched here and elsewhere and can’t figure out why it is not recognizing the tests. Each test starts with test and the other portions of the unitt…

Django REST Framework and FileField absolute url

I’ve defined a simple Django app that includes the following model: (Technically yes, that could have been an ImageField.) In a template, it’s easy enough to include the MEDIA_URL value (duly coded in settings.py) as a prefix to the thumbnail URL. The following works fine: Using DRF, I’ve de…

Problems with decoding from command prompt [python]

I have the following problem. I have a german text saved in .txt UTF-8 format, and I’d like to print it out with python. Here’s my code: It works perfectly in IDLE, but when I save my code and run it from the command prompt, it raises error, specifically: In my particular case, the text is “…

Antialiasing shapes in Pygame

I’m using Pygame to draw some things. The problem is that they have a lot of aliased edges: I want to make them softer, like this: My idea so far was to draw the shape in double size, and then use to shrink it to the size I want. Unfortunately if I’m drawing my shapes on a transparent surface, the

Python quicksort – one list – swaps

**I need to make a quicksort algorithm but so that it uses only one list and does swaps inside of it. I managed to make it “sort” or position the first element but now i don’t know how to implement the recursion. The biggest problem I’m having is how to recursively work on a part of th…

Can I change the title bar in Tkinter?

I’m using Tkinter as GUI for my program, but as I see, many programs don’t have standard look as Tkinter does. By standard look I mean standard title bar, borders, etc. For example, Tkinter’s title bar: vs GitHub’s title bar: See how they have their own custom exit, resize and minimize…