Ask Your Question
0

Appending local binary pattern of image (having 200 channels) taken over 3 channels at a time

asked 2019-11-02 01:26:28 -0600

Sandeep Kumar gravatar image

updated 2019-11-02 02:02:57 -0600

berak gravatar image

I am unable to append the local binary patterns of image having 200 channels taking 3 channels at a time. hsi_data is my image,img_lbp is local binary pattern of my image hsi_data taking 3 channels at a time. I want to append all the local binary patterns taken over 3 channels to img_lbp_appended. Please refer to my code attached. Can anyone tell me my mistake. ..

for k in range(0,199,3):
   if k==198:
     break
   else:
     image_file = hsi_data[:,:,k:k+3]
     img_bgr = image_file
     height, width, channel = img_bgr.shape
     img_gray = cv2.cvtColor(img_bgr,cv2.COLOR_BGR2GRAY)
     img_lbp = np.zeros((height, width,3), np.uint8)

     for i in range(0, height):
        for j in range(0, width):
            img_lbp[i, j] = lbp_calculated_pixel(img_gray, i, j)
     img_lbp_appended=np.zeros((height, width,200),np.uint8)
     img_lbp_appended=np.append(img_lbp_appended,img_lbp,axis=2)

..

edit retag flag offensive close merge delete

Comments

where's the problem ? error msg ?

berak gravatar imageberak ( 2019-11-02 02:34:19 -0600 )edit

I am getting the img_lbp_appended as numpy array with zero values.

Sandeep Kumar gravatar imageSandeep Kumar ( 2019-11-02 02:42:49 -0600 )edit

what is the intent behind:

img_lbp_appended=np.zeros((height, width,200),np.uint8)

? why 200 channels (your lbp image only has 1 ?) ? why is it repeated for each image triplet ?. (it probably should go before anything else)

berak gravatar imageberak ( 2019-11-02 02:46:17 -0600 )edit

I have used a code which is available in github which works for image of 3 channels. My intention is to append all the LBPs to get the LBP of my image that is having 200 channels.

Sandeep Kumar gravatar imageSandeep Kumar ( 2019-11-02 02:58:01 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-11-02 03:07:45 -0600

berak gravatar image

My intention is to append all the LBPs to get the LBP of my image that is having 200 channels.

why not write into the resp. channel in the 1st place ?

# this will hold our final result:
height, width, channels = hsi_data.shape
lbp_final = np.zeros((height, width, channels),np.uint8)

for k in range(0, channels):
     image_gray = hsi_data[:,:,k]
     for i in range(0, height):
        for j in range(0, width):
            lbp_final[i, j, k] = lbp_calculated_pixel(img_gray, i, j)

(untested, i don't have python)

edit flag offensive delete link more

Comments

1

Thank you Berak. I have successfully executed the above code. It is working.

Sandeep Kumar gravatar imageSandeep Kumar ( 2019-11-02 03:29:52 -0600 )edit

btw, check border conditions in the lbp code you try with again.

berak gravatar imageberak ( 2019-11-02 04:10:23 -0600 )edit

How can we check the Border conditions?

Sandeep Kumar gravatar imageSandeep Kumar ( 2019-11-02 05:40:15 -0600 )edit

think about what your code does.

what happens at pixel (0,0) ? does it have a "left" neighbour, or a "top" one ?

what does numpy do here (overflow condition) and is the result correct ?

berak gravatar imageberak ( 2019-11-02 05:55:08 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-11-02 01:26:28 -0600

Seen: 313 times

Last updated: Nov 02 '19