• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 195

Backtrace:

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/views/question.php
Line: 195
Function: _error_handler

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/controllers/Questions.php
Line: 416
Function: view

File: /home/u125378470/domains/lawhelpguru.org/public_html/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to detect seed with hue or threshold algorithm with opencv?

I have a two images..

First image ... https://ibb.co/K0NYbZH for hue

Second İmage ... https://ibb.co/DrPbnH0 for threshold

first questions: My algorithm hue algirthm doesnt work. not enough for detect and roi .. First image ... https://ibb.co/K0NYbZH for hue


import cv2
from imutils import contours
import math
import numpy as np
# ilk resim ıcın lınk 
# https://ibb.co/K0NYbZH
image = cv2.imread('basler1.bmp',1)

#image = cv2.resize(image, (512,512))
original = image.copy()
print(original.shape[0]) # 1080
print(original.shape[1]) # 1440


hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

lower = np.array([34,22,55])
upper = np.array([54,255,255])

mask = cv2.inRange(image, lower , upper )
#res = cv2.bitwise_and(image,image, mask= mask)
cnts = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
num = 0

for c in cnts:
    x,y,w,h = cv2.boundingRect(c)
    
    if (math.fabs(w - h) < 2 ) | (math.fabs(x - y) < 2):
        continue
    print(x,y,w,h)
    cv2.rectangle(image, (x, y), (x + w, y + h), (136,255,12), 1)

    num += 1
cv2.imshow('image',image)
cv2.imshow('mask',mask)
cv2.waitKey()

or second choose... How to best detect with threshold seed detect. My algorithm not enough for detect and roi .. Second İmage ... https://ibb.co/DrPbnH0 for threshold

import cv2
from imutils import contours
import math
# ikinci resim ıcın lınk
# https://ibb.co/DrPbnH0
image = cv2.imread("Basler_acA1440-73gc__40038474__20200417_134730369_0831.tiff")
original = image.copy()
print(original.shape[0]) # 1080
print(original.shape[1]) # 1440

gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
 
thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]

cnts = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
(cnts, _) = contours.sort_contours(cnts, method="left-to-right")
num = 0
for c in cnts:
    x,y,w,h = cv2.boundingRect(c)
 
    if (math.fabs(w - h) < 5 ) | (math.fabs(x - y) < 5):
        continue
    print(x,y,w,h)
    cv2.rectangle(image, (x, y), (x + w, y + h), (136,255,12), 1)
    ROI = original[y:y+h, x:x+w]

    num += 1

cv2.imshow('image', image)
cv2.waitKey()

Can you help me thanks ...