Ask Your Question

Stephane's profile - activity

2020-09-28 13:12:04 -0600 received badge  Student (source)
2020-04-28 08:37:40 -0600 received badge  Notable Question (source)
2019-10-06 11:14:05 -0600 received badge  Popular Question (source)
2019-03-10 19:08:45 -0600 marked best answer SimpleBlobDetector Algorithm

I am curious as to how OpenCV's SimpleBlobDetector algorithm works. Are there any papers or documentation regarding the actual algorithm behind it?

2019-03-07 22:28:55 -0600 asked a question SimpleBlobDetector Algorithm

SimpleBlobDetector Algorithm I am curious as to how OpenCV's SimpleBlobDetector algorithm works. Are there any papers or

2019-02-11 11:59:50 -0600 asked a question Code behaves different after updating OpenCV

Code behaves different after updating OpenCV I have updated OpenCV to the newest version (on a mac). My script was previ

2018-11-13 18:11:06 -0600 asked a question findContours on generate image doesn't work

findContours on generate image doesn't work I have an image of a graph. I perform some preprocessing functions on the im

2018-11-06 12:32:41 -0600 asked a question Find the color of SimpleBlobDetection keypoints

Find the color of SimpleBlobDetection keypoints I am attempting the sort blobs identified using SimpleBlobDetection by t

2018-11-05 15:22:38 -0600 commented question Improving Simple Blob Detection

@ameyparanjape I have tried varying the parameters, however, I continuously get the same results. When I change the minC

2018-11-05 14:38:01 -0600 asked a question Improving Simple Blob Detection

Improving Simple Blob Detection I am using a simple blob detection to detect the moles in the input image below: And t

2018-11-05 14:38:01 -0600 asked a question Improving Simple Blob Detection

Improving Simple Blob Detection I am using a simple blob detection to detect the moles in the input image below: And t

2018-04-01 05:20:55 -0600 marked best answer Python - Trying to Find Average Intensity of a ROI

I am trying to find the average intensity of a binarized ROI. If the average intensity of the ROI is greater than a cutoff point (meaning if the ROI is mostly white), I want a rectangle to be drawn around it. Below is my code to do that. The output, however, is an image where almost every single ROI has a rectangle drawn around it, even the ones that are completely black (meaning its average ROI intensity is 0.0). I would really appreciate your help, thanks.

The block of code with the problem:

 for i in range (0,height, int(boxsize)):
    for j in range (0,width, int(boxsize)):
        #1. DRAW THE BLOCKS
        roi_gray = edge[i:i+int(boxsize),j:j+int(boxsize)]
        #2. FIND INTENSITY OF ROI
        roi_avg_intensity = np.mean(roi_gray)
        #3. BASED ON THAT, SEE IF ROI IS AN OBSTACLE OR NOT
        if roi_avg_intensity > cut_off_point:
            cv2.rectangle(edge, (j,i), (j+int(boxsize), i+int(boxsize)),(128,128,128),2)
            #4. ADD TO ARRAY

Output image:

https://imgur.com/a/oWgVP

Raw image: https://imgur.com/a/HAYT9

All of the code:

import cv2
import numpy as np
import scipy.signal
import math


roomimg = cv2.imread("/Users/2020shatgiskessell/Desktop/medium2.jpg")

#edge detection
ret, thresh = cv2.threshold(roomimg, 127, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C)
edge = cv2.Canny(thresh, 100, 200)
height,width,channels = roomimg.shape
matrix = [] 
column = []

#define the dimensions of the grid
def estimate_noise(I):

  H, W = I.shape

  M = [[1, -2, 1],
       [-2, 4, -2],
       [1, -2, 1]]

  sigma = np.sum(np.sum(np.absolute(scipy.signal.convolve2d(np.array(I), M))))
  sigma = sigma * np.sqrt(0.5 * np.pi) / (6 * (W-2) * (H-2))

  return sigma

boxsize = math.pow(estimate_noise(edge),-0.708)* 112.32

#defines what are obstacles and what are not
cut_off_point = 15

#U HAVE TO CHANGE CUT OFF POINT BASED ON EVERY IMAGE

for i in range (0,height, int(boxsize)):
    for j in range (0,width, int(boxsize)):
        #1. DRAW THE BLOCKS
        roi_gray = edge[i:i+int(boxsize),j:j+int(boxsize)]
        #2. FIND INTENSITY OF ROI
        roi_avg_intensity = np.mean(roi_gray)
        #3. BASED ON THAT, SEE IF ROI IS AN OBSTACLE OR NOT
        if roi_avg_intensity > cut_off_point:
            cv2.rectangle(edge, (j,i), (j+int(boxsize), i+int(boxsize)),(128,128,128),2)
            #4. ADD TO ARRAY


cv2.imshow('Image Edges', edge)

if cv2.waitKey(0) & 0xff == 27:
    cv2.destroyAllWindows()
2018-03-30 09:06:57 -0600 commented answer Python - Trying to Find Average Intensity of a ROI

I commented out the ret, thresh = cv2.threshold(roomimg, 127, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C) line, but I still get

2018-03-29 01:18:59 -0600 commented question Python - Trying to Find Average Intensity of a ROI

@moHe I added the raw image to my original question. The cut_off_point is also set to 15 because an average ROI intensit

2018-03-29 01:17:14 -0600 edited question Python - Trying to Find Average Intensity of a ROI

Python - Trying to Find Average Intensity of a ROI I am trying to find the average intensity of a binarized ROI. If the

2018-03-29 01:16:50 -0600 edited question Python - Trying to Find Average Intensity of a ROI

Python - Trying to Find Average Intensity of a ROI I am trying to find the average intensity of a binarized ROI. If the

2018-03-29 01:16:01 -0600 received badge  Enthusiast
2018-03-27 08:15:32 -0600 asked a question Python - Trying to Find Average Intensity of a ROI

Python - Trying to Find Average Intensity of a ROI I am trying to find the average intensity of a binarized ROI. If the

2018-03-17 06:12:11 -0600 commented answer Find Average Intensity of ROI

could you please elaborate what that means, thanks.

2018-03-17 05:57:18 -0600 commented answer Returning Threshold Values

I fixed the issue, and when I print the retval I get values like 187.0, 119.0, etc. What exactly do these values mean? L

2018-03-17 05:55:49 -0600 received badge  Supporter (source)
2018-03-17 05:55:48 -0600 marked best answer Returning Threshold Values

I am trying to return the average threshold value for a binary ROI, however, I keep on getting a weird output.

My code is :

import cv2
import numpy as np

img = cv2.imread("/Users/2020shatgiskessell/Desktop/roomimage.jpg")
roomimg = cv2.resize(img, (0,0), fx=0.5, fy=0.5)
gray = cv2.cvtColor(roomimg, cv2.COLOR_BGR2GRAY)

#edge detection 
ret, thresh = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY_INV)
edge = cv2.Canny(thresh, 100, 200)

#create nodes by iterating through 10x10 blocks and checking the neighbors

height,width,channels = roomimg.shape

for i in range (0,width,10):
    for j in range (0,height,10):
        #roi is null for some reason
        roi_gray = cv2.rectangle(edge, (i,j), (i+10, j+10), (128, 128, 128), 1)
        cv2.imshow('ROI', roi_gray)
        retval, threshold = cv2.threshold(roi_gray, 10, 255, cv2.THRESH_OTSU)
        threshed_roi_gray = threshold
        print (threshed_roi_gray)
        #see what threshold value is, assign roi a 1 or 0, and add it to list to be traversed



cv2.imshow('Image Edges', edge)
if cv2.waitKey(0) & 0xff == 27:
    cv2.destroyAllWindows()

And the output values I get are:

[255   0   0 ...,   0   0   0]
[255   0   0 ...,   0   0   0]]
[[255 255 255 ...,   0   0   0]
[255   0   0 ...,   0   0   0]
[255   0   0 ...,   0   0   0]
....

I am confused what these values are. I thought that [255 0 0] was the color code for red, while my image is only black and white. I am also confused why 2 data values are returned for each ROI threshold, instead of just 1. I would appreciate your help, thanks.

2018-03-17 05:44:48 -0600 marked best answer Convert Image to Occupancy Grid

I was wondering how I might turn a bird's eye view image of a map into an occupancy grid. I use an edge detection algorithm to detect obstacles in the bird's eye view image and would like to then translate this information into an occupancy grid (the black squares would be obstacles as detected by the edge detection algorithm, and the white squares would be free space).

The image I would like to convert:

https://imgur.com/a/6UL6g

I would like to turn the image above into something along the lines of this (the image below is just crudely hand drawn)

https://imgur.com/a/vPQNu

My code for edge detection:

import cv2
import numpy as np

roomimg = cv2.imread("/Users/2020shatgiskessell/Desktop/roomimage.jpg")
gray = cv2.cvtColor(roomimg, cv2.COLOR_BGR2GRAY)

gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0,0.04)

dst = cv2.dilate(dst, None)

roomimg[dst>0.01*dst.max()]=[0,0,255]


cv2.imshow('dst',roomimg)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()
2018-03-17 05:44:48 -0600 received badge  Scholar (source)
2018-03-17 05:13:49 -0600 commented answer Returning Threshold Values

Thank you so much! When I print the retval value, I get 0.0 for everything. Is that just because the ROI is null for som

2018-03-17 02:00:57 -0600 asked a question Returning Threshold Values

Returning Threshold Values I am trying to return the average threshold value for a binary ROI, however, I keep on gettin

2018-03-16 05:26:12 -0600 asked a question Find Average Intensity of ROI

Find Average Intensity of ROI I was wondering how to find the average intensity of a gray scaled ROI. I currently use th

2018-03-15 22:48:06 -0600 edited question Convert Image to Occupancy Grid

Convert Image to Occupancy Grid I was wondering how I might turn a bird's eye view image of a map into an occupancy grid

2018-03-15 22:09:25 -0600 edited question Convert Image to Occupancy Grid

Convert Image to Occupancy Grid I was wondering how I might turn a bird's eye view image of a map into an occupancy grid

2018-03-15 22:06:00 -0600 received badge  Editor (source)
2018-03-15 22:06:00 -0600 edited question Convert Image to Occupancy Grid

Convert Image to Occupancy Grid I was wondering how I might turn a bird's eye view image of a map into an occupancy grid

2018-03-15 22:04:40 -0600 asked a question Convert Image to Occupancy Grid

Convert Image to Occupancy Grid I was wondering how I might turn a bird's eye view image of a map into an occupancy grid

2017-12-23 09:07:20 -0600 commented question Installing OpenCV Not Working

It does not install the parameters however

2017-12-23 08:56:20 -0600 commented answer Installing OpenCV Not Working

I followed their instructions. The commands are from that tutorial, but they do not have my error under the troubleshoot

2017-12-23 08:33:43 -0600 asked a question Installing OpenCV Not Working

Installing OpenCV Not Working When I type in the following, brew tap homebrew/science brew install opencv3 --wi