How to separate road from parking lot when they have same colour

2 Ansichten (letzte 30 Tage)
Hi, i'm a university student that is working on a image-processing project. The project is about free parking-lot detection using matlab. I'm struggling finding a solution that may be able to logically separate the road from the parking lots beacause they seem to have the same colour.
Is it possible to do it without training a neural network? If yes, how?
I have already read this link: https://it.mathworks.com/matlabcentral/answers/524849-available-free-parking-space-detection-image-analysis-algorithm that has been used as the core of the code but i modified it by creating a binary mask on matlab by myself (without using photoshop as it was done in that case) got by colour thresholding, adding a black frame and using erosion operations on the binary image.
I've attached a pdf with the testing results obtained on different parking lots and i would like to solve the "case 6" without being forced to manually draw a black rectangle in the middle to cover the road.

Akzeptierte Antwort

Image Analyst
Image Analyst am 12 Mär. 2023
Not too hard. You don't need a neural network. You can just use traditional methods. Try this (untested)
  1. Threshold (segment) the image to get the white lines only in stripeMask
  2. Use any to determine which rows have a white stripe in them. stripeRows = any(stripeMask, 2)
  3. Use false and true to get a binary image with a band across the middle that is just the road alone and has no stripes in it. roadMask = false(rows, columns); roadMask(stripeRows, :) = true; topRoadRow = find(~stripeRows, 1, 'first'); bottomRoadRow = find(~stripeRows, 1, 'last')
  4. Use any() to get columns in the upper part that do not have a white pixel in the mask. spaceMask = false(rows, columns); spaceColumns = any(mask(1:topRoadRow, :), 1)
  5. Make those columns true in the mask from line 1 down to the top of the road band across the middle. spaceMask(1:topRoadRow - 1, spaceColumns) = true
  6. Repeat Steps 4 and 5 for the bottom part of the image (below the center roadway).
If you can't figure it out, attach the image of your empty parking lot. The algorithm works only for cases where the road and parking spaces are fairly well aligned with the image, not at a big angle.
For convenience for others, I'm attaching my original demo from the link you gave.
  3 Kommentare
Christian Loconsole
Christian Loconsole am 14 Mär. 2023
Bearbeitet: Christian Loconsole am 14 Mär. 2023
Thank you for everything!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by