Interactive pixel information of an image

There a couple of different ways to go about this. You can monkey-patch ax.format_coord, similar to this official example. I’m going to use a slightly more “pythonic” approach here that doesn’t rely on global variables. (Note that I’m assuming no extent kwarg was specified, similar to the matplotlib example. To be fully general, you need … Read more

Calculating percentage of Bounding box overlap, for image detector evaluation

For axis-aligned bounding boxes it is relatively simple. “Axis-aligned” means that the bounding box isn’t rotated; or in other words that the boxes lines are parallel to the axes. Here’s how to calculate the IoU of two axis-aligned bounding boxes. def get_iou(bb1, bb2): “”” Calculate the Intersection over Union (IoU) of two bounding boxes. Parameters … Read more

How do I remove the background from this kind of image?

The following code should get you started. You may want to play around with the parameters at the top of the program to fine-tune your extraction: import cv2 import numpy as np #== Parameters ======================================================================= BLUR = 21 CANNY_THRESH_1 = 10 CANNY_THRESH_2 = 200 MASK_DILATE_ITER = 10 MASK_ERODE_ITER = 10 MASK_COLOR = (0.0,0.0,1.0) # In … Read more

Interactive pixel information of an image in Python?

There a couple of different ways to go about this. You can monkey-patch ax.format_coord, similar to this official example. I’m going to use a slightly more “pythonic” approach here that doesn’t rely on global variables. (Note that I’m assuming no extent kwarg was specified, similar to the matplotlib example. To be fully general, you need … Read more

How to de-skew a text image and retrieve the new bounding box of that image Python OpenCV?

Here’s a modified implementation of the Projection Profile Method to correct skewed images as described in Projection profile based skew estimation algorithm for JBIG compressed images. After obtaining a binary image, the idea is to rotate the image at various angles and generate a histogram of pixels in each iteration. To determine the skew angle, … Read more