Ask Your Question
0

colormodel threshold sample code behaving oddly

asked 2013-03-13 00:58:45 -0500

christinasc gravatar image

Having a bit of trouble getting the following code to work - I get a completely white image. That doesn't seem correct.... any ideas why?

>>> cm = ColorModel()
>>> cm.add(color.RED)
>>> cm.add(color.BLUE)
>>> result = cm.threshold(Image("lenna")
>>> result.show()

simplecv.org/docs/SimpleCV.html#i/SimpleCV.ColorModel.ColorModel/threshold

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-03-13 10:20:00 -0500

kscottz gravatar image

So there are two things to realize about the color model class. First, you need to feed a bunch of colors to have it recognize what you want. Second it returns pixels in the model as black, and pixels not in the model as white, this is to support the default behavior in find blobs. You can use the invert command to fix this really quickly. We are going to fix this in SimpleCV 2.0

Here is an example:

cm = ColorModel()
img = Image('lenna')
cm.add(img[0:150,0:150])
out = cm.threshold(img)
out.show()

Here is the result.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-03-13 00:58:45 -0500

Seen: 116 times

Last updated: Mar 13 '13