Cant display the image after applyting exposed elbp function in python

asked 2015-11-30 05:21:58 -0600

czc080 gravatar image

I am trying to display an image after applying elbp function to a gray-scale image, the function was exposed manually in the face module for python. here's the code:

LBP = cv2.face.elbp(gray_roi,1,8)
cv2.imshow("Face",LBP)

But however, what I got is a pure black window,also I noticed that the cols and rows are always smaller than the original image by 2,here is the error information:

could not broadcast input array from shape (95,95) into shape (97,97)

I noticed one other ppl asked the same question but was using c++ instead:

link text

But what I cant understand is what he meant by normalized the image to fit the screen rendering range?

edit retag flag offensive close merge delete

Comments

1

Your values in the black image are less than 10, so you cannot see them, they are almost black. Do a normalize with normType=NORM_MINMAX on the lbp image (or a copy of it), then display it.

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-11-30 06:00:00 -0600 )edit
1

a:) put a cv2.waitKey(some_millis) behind imshow() (yawn....)

b:) with lbp images you have to spare a border of the size of the neighbour radius, but you'd have to show us the code, to know what's happening exactly.

c:) where is that code from ? it's not opencv's.

berak gravatar imageberak ( 2015-11-30 06:00:22 -0600 )edit

Hi! Thx for the solution, I tried to normalize the image with :

cv2.normalize(XX,XX,0,255,cv2.NORM_MINMAX)

but it doesn't work, what I did was to multiply the image matrix by a value like 32 ,and finally I can see the image,I wonder why normallize doesnt work though

czc080 gravatar imageczc080 ( 2015-11-30 18:31:39 -0600 )edit

and regarding to @berak questions a:) why do I need to put wait after imshow()? c:) the code is from the face module in the opencv_contrib,here is the directory: "/home/pi/opencv_contrib-3.0.0/modules/face/src/lbph_faces.cpp"

czc080 gravatar imageczc080 ( 2015-11-30 18:34:33 -0600 )edit

"a:) why do I need to put wait after imshow()?" Because the displaying (rendering) is done in the waitKey()

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-12-01 02:17:32 -0600 )edit