-2

I am working on a task to detect patches on road. However, in pre-processing, I am unable to figure out what technique should I use to take out patches using thresholding. Image of a Road with patch in it

I have used several thresholding techniques out of which Otsu's Multi-level thresholding Algorithm gave the best result among them. Thresholded Image using Otsu's Multi-level Thresholding Method

The thresholding method works on this image, however it does not work well with images with different surfaces like the one below.

Thresholded Image

I am looking is for a more general approach to this problem that would use thresholding or any other technique to take out patch areas in different surfaces of road and apply further analysis onto it.

Here's my code:

import cv2
import numpy as np
import os
from skimage.filters import threshold_multiotsu

def threshold(image):
    thresh = threshold_multiotsu(img, 3)

    ret, thresh1 = cv2.threshold(img, thresh[0], 255, cv2.THRESH_BINARY)
    ret, thresh2 = cv2.threshold(img, thresh[1], 255, cv2.THRESH_BINARY_INV)

    thresh3 = cv2.bitwise_and(thresh1, thresh2)

    return thresh3

if __name__ == "__main__":

    path = './Images/Set 124/images/GX010122_frame_1399.jpg'
    image = cv2.imread(path)
    gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    blur_image = cv2.medianBlur(gray_image, 11)

    equalize_image = cv2.equalizeHist(blur_image)

    multi_otsu = threshold(equalize_image)

    cv2.imshow('Threshold Result', multi_otsu)
    cv2.waitKey(0)

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
hawaee
  • 137
  • 1
  • 1
  • 4
  • 4
    This seems more of an idea/conceptual issue than a code issue per se; if you couldn't do this without code, just from a pure algorithmic approach, how would you know how to do it with code? I think maybe you need a better understanding of what you're doing before you can ask about code; since I think it's not an issue with code knowledge that's the issue here, but with the knowledge of the problem itself, code-independent. And since this is a site for code help, it might not be the perfect site for this. – Random Davis Aug 30 '23 at 17:24
  • 1
    I don't think there's any general solution to this. you should look into segmentation models – Musabbir Arrafi Aug 30 '23 at 17:25
  • @RandomDavis I agree with your opinion. This is a code related site but since it is also an image processing problem, I reckoned someone with more knowledge or experience would explain the problem in better terms(conceptually). If you know any related sites let me know. Thanks. – hawaee Aug 30 '23 at 17:39
  • @hawaee maybe something here? https://meta.stackexchange.com/questions/130524/which-stack-exchange-website-for-machine-learning-and-computational-algorithms – Random Davis Aug 30 '23 at 18:03
  • use the state of the art: DL/AI for semantic segmentation. anything less will not work. – Christoph Rackwitz Aug 31 '23 at 07:57

0 Answers0