Closed deter3 closed 7 years ago
Hi, The issue is that when you calculate LBP on an image its size will reduce depending on the size of the radius parameter!
In you example, you are calculating with the default value of r=1
and as such your image is 2 pixels smaller in width and height.
You can either take care of this yourself and make the mask smaller or use the built-in parameter borderCopy=True
: l.calcLBP(image1, 1, True)
Hope this helps
yes , it worked now and thanks a lot ! I noticed you also update the python test sample , which is easier to understand how to implement it .
Hi Glad it worked out. I found the old test case insufficient myself so changed it :)
Hi ,
Is there any plan to implement GPU for masked image ? I just compiled on GPU ubuntu , and found GPU can not calculate masked image . It requires 30-40 seconds to calculate 500 masked patches for one image on CPU , which is the bottleneck for my project . So I tried GPU and wish to speed up LBP calculation .
thanks
The GPU implementation was just a test. It is not complete or optimal!
I am not a GPU expert so I'm not going to expand that part. But do feel free to contribute if you can.
I am having 400-500 patches per image . Applying hf-lbp on masked images is really time and cpu consuming job , which takes around 40-60s to accomplish the features extraction . I will have to learn some CUDA programming to see the possibilities of applying hf-lbp on masked images . I will update to you if I have some clue of how to do it .
Well this sounds like a great task to apply GPU processing. Good luck and love to hear how you go about it
using python2.7 and opencv 2.4.13 .
image_path ="~/237720229_2.jpg" image1 = cv2.imread(image_path,cv2.IMREAD_GRAYSCALE) labelMask = np.zeros(image1.shape[:2], dtype="uint8") labelMask[0:20,0:20] = 255 l = lbp.LBP(10, lbp.LBP_MAPPING_HF) l.calcLBP(image1) hist = l.calcHist(labelMask).getHist() print hist.shape
I got an error
`OpenCV Error: Assertion failed (mask.size() == imsize && mask.channels() == 1) in histPrepareImages, file /Users/deter3/downloads/opencv-2.4.13/modules/imgproc/src/histogram.cpp, line 161 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/deter3/downloads/opencv-2.4.13/modules/imgproc/src/histogram.cpp:161: error: (-215) mask.size() == imsize && mask.channels() == 1 in function histPrepareImages
Abort trap: 6`
I checked both image and mask shape are the same , both dtype are unit8 .
If i use hist = l.calcHist().getHist() , no problem . But it is histogram for the whole image .