Skip to content

Instantly share code, notes, and snippets.

@femioladeji
Created July 16, 2017 11:11
Show Gist options
  • Save femioladeji/d661f291fc082174d45f6fbeba762087 to your computer and use it in GitHub Desktop.
Save femioladeji/d661f291fc082174d45f6fbeba762087 to your computer and use it in GitHub Desktop.
Connected Component Analysis on the binary image to identify connected regions
from skimage import measure
from skimage.measure import regionprops
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import localization
# this gets all the connected regions and groups them together
label_image = measure.label(localization.binary_car_image)
fig, (ax1) = plt.subplots(1)
ax1.imshow(localization.gray_car_image, cmap="gray");
# regionprops creates a list of properties of all the labelled regions
for region in regionprops(label_image):
if region.area < 50:
#if the region is so small then it's likely not a license plate
continue
# the bounding box coordinates
minRow, minCol, maxRow, maxCol = region.bbox
rectBorder = patches.Rectangle((minCol, minRow), maxCol-minCol, maxRow-minRow, edgecolor="red", linewidth=2, fill=False)
ax1.add_patch(rectBorder)
# let's draw a red rectangle over those regions
plt.show()
@askaydevs
Copy link

module 'localization' has no attribute 'binary_car_image'

@askaydevs
Copy link

You are clearly not able to solve this for a year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment