Flattening nested lists or arrays in Python
Posted 2nd June 2023
There may be a requirement to flatten a list of lists in Python in order to extract useful information more easily. Here’s a procedure for flatting nested lists using NumPy.
Batch rename files using a CSV in Python
Posted 19th January 2023
Use this simple Python script to change hundreds or thousands of file names automatically, based on a CSV. This procedure will work on all operating systems.
List directory contents in CSV file using Python
Posted 18th January 2023
Do you need to compile a list of all of the files in a folder or directory? This can be automated using a simple Python script which will save a list of the files (and their full paths) into a CSV file that can be read in Excel.
Structuring elements in Python
Posted 1st September 2022
Some simple methods to generate structuring elements as part of an image morphology pipeline in Python.
Add your Conda environment to your Jupyter Notebook
Posted 31st May 2022
By default, Jupyter Notebook will only display a single kernel (called ipykernel) when installed in a new environment. Here’s a procedure for choosing another Conda environment in a Jupyter Notebook.
Blob analysis with OpenCV in Python
Posted 10th December 2021
Here’s my methodology for performing a blob analysis from binary images in OpenCV using Python code.
Fit an inscribing circle to a shape in OpenCV
Posted 30th October 2021
The largest possible circle that can be drawn interior to a plane figure is called an inscribing circle. This can easily be fitted to a binary shape in OpenCV.
Skip cells when running Jupyter Notebook scripts
Posted 27th September 2021
There is a surprisingly simple way to turn off specific cells in Jupyter Notebook without having to manually comment-out chunks of code.
Bounding rectangles in Python OpenCV
Posted 20th July 2021
There are two methods in OpenCV to derive a bounding rectangle and extract the relevant values of an object or series of objects in an image.
Managing RAW photos with Python
Posted 23rd April 2021
Use Python to recursively scan directories and remove unused and redundant CR2 files.