I am designing morphological operations in OpenCV. I am trying to mimic the functions remove
and bridge
in Matlab's bwmorph. To do this I referred to the function definition of bwmorph.m, there I obtained the Look up table arrays for remove and bridge.
After that step the procedure is same for both Matlab and OpenCV.
lut(img,lutarray,img)
Problem is that Matlab uses a 512 element (9bit) look up table scheme while OpenCV uses a 256 element (8bit) look up scheme, how do I use the Matlab lutarray in OpenCV?
After doing some research I came across this post.
What does the person mean when they're saying that they "split" the image from 0-512 and then into two parts?
Is the above method even correct? Are there any alternates to doing this?
bwlookup(bw,lut)
http://se.mathworks.com/help/images/ref/bwlookup.html
or internally,
applylut
both perform a 2-by-2 or 3-by-3 neighborhood operation on a binary (black & white) image, whereas OpenCV'scv::LUT
performs a per pixel gray level transform (closely related tointlut
in MATLAB). An example of latter is performing a gamma correction on gray level image.To my knowledge, there is no neighborhood
bwlookup
implementation in OpenCV. However, following the description of MATLAB'sbwlookup
, you can write it yourself.I tested it against
remove
andbridge
so should work. Hope that helps.Edit: After checking against a random lookup table,
I flipped the order the indices appear in the lookup table (doesn't matter if the operation is symmetric).