Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

blob finding from a thresholded image

Hi, Im using openCv and simpleCv in my project, simpleCv mainly for blob analysis. I loaded a simplecv image by calling img = Image(ROI) where ROI is a thresholded image I had previously made using opencv functions. I find however that Im getting this error

" File "..BlobProcess.py", line 19, in FindBlobs blobs = im.findBlobs() File "C:\Python27\lib\site-packages\SimpleCV\ImageClass.py", line 3062, in findBlobs blobs = blobmaker.extractFromBinary(self.binarize(threshval, 255, threshblocksize, threshconstant).invert(), File "C:\Python27\lib\site-packages\SimpleCV\ImageClass.py", line 2905, in binarize cv.Threshold(self.getGrayscaleBitmap(), newbitmap, thresh, float(maxv), cv.CVTHRESHBINARYINV + cv.CVTHRESHOTSU) File "C:\Python27\lib\site-packages\SimpleCV\ImageClass.py", line 1763, in getGrayscaleBitmap cv.CvtColor(self.getBitmap(), self.graybitmap, cv.CV_BGR2GRAY) error: scn == 3 || scn == 4"

So what I did to solve this problem was just save the image as a file, and then reload it from simplecv directly. Obviously this is not a great solution . Can someone help me figure out how to fix this? BTW, I think findBlobs should logically be able to handle an input argument which is already a binary CVmat and not expect to get a gray scale or colour image only. Thanks Harsha

blob finding from a thresholded image

Hi, Im thanks for your reply.And sorry,I think I wasnt clear with my problem.I created a 8bit,binary thresholded CvMat using openCv OpenCV and simpleCv then passed that into simple cv with the Image function. That worked ok. Then I tried to do findBlobs on that image in simpleCV and got the error message I posted in my project, simpleCv mainly for blob analysis. I loaded a simplecv image by calling img = Image(ROI) where ROI last post.So the issue is a with findblobs which seems to fail if you pass it an already thresholded image I had previously made using opencv functions. I find however that Im getting this error

" File "..BlobProcess.py", line 19, in FindBlobs blobs = im.findBlobs() File "C:\Python27\lib\site-packages\SimpleCV\ImageClass.py", line 3062, in findBlobs blobs = blobmaker.extractFromBinary(self.binarize(threshval, 255, threshblocksize, threshconstant).invert(), File "C:\Python27\lib\site-packages\SimpleCV\ImageClass.py", line 2905, in binarize cv.Threshold(self.getGrayscaleBitmap(), newbitmap, thresh, float(maxv), cv.CVTHRESHBINARYINV + cv.CVTHRESHOTSU) File "C:\Python27\lib\site-packages\SimpleCV\ImageClass.py", line 1763, in getGrayscaleBitmap cv.CvtColor(self.getBitmap(), self.graybitmap, cv.CV_BGR2GRAY) error: scn == 3 || scn == 4"

So what I did image. (because it does thresholding too inside it) Ive been trying to solve this problem was just save the image as a file, and then reload it from simplecv directly. Obviously this is not a great solution . Can someone help me figure out how to bypass that part of code within findBlobs so that i can fix this? BTW, I think findBlobs should logically be able the problem but not yet figured it out. One thing Id like to handle know is if theres any special colourspace designated to a thresholded image(like in matlab its called a logical,not a grayscale).If not, is there someway to detect if an input argument which image is already a binary CVmat and not expect thresholded/binary? If I figure this out , Ill let you know, else Ill add it to get a gray scale or colour image only. Thanks Harshathe github. thanks