Converting image to uint8 for working with houghcircles

asked 2015-03-09 05:47:46 -0500

spinter696 gravatar image

Hi,

I explain my problem, I am using python opencv 3.0.0 and sci-kit lib.

I am trying to detect circles from images using hough circles but my dataset is not so good, so first of all, I do an adaptive equalization histogram with sci-kit and after I try to detect circles; the problem, the function I used to make the adaptive equalization returns me an uint16 image but Hough circles requires a uint8.

There is some way to convert the image to uint8 after doing the equalization??? Or it exists some function in opencv which does the adaptive equalization?? I was searching but I found nothing. :(

I write my code just down here:

#prerequisites: I use cv2.imread to read an image in img variable

import cv2
import numpy as np
from skim age import exposure

def findCircles(img):
    allCircles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,10,param1=100,param2=30,minRadius=10,
    maxRadius=40)
    print allCircles


def main():
    img_adapteq=exposure.equalize_adapthist(img)
    findCircles(img_adapteq)

if __name__ == "__main__":
    main()
edit retag flag offensive close merge delete

Comments

Use the img_adapteq.convertTo(dest,CV_8U) or normalize(img_adapteq,dest,0,255,CV_8U) functions. Check the docs for description of these functions.

kbarni gravatar imagekbarni ( 2015-03-09 06:57:04 -0500 )edit