otsu threshold in python

A

azrael

Hy guys.
I'd like to ask you for a favour.
I tried several times to implement the otsu threshold filter in
python. but I failed every time. I found the soucre code i n Java from
the ImageJ project but I never worked in Java and there have been used
some built in Java functions which I don't know how they behave. I
also found the otsu threshold in the ia636 python module and would
like only this filter and don't want to import this library.
Is there anyone who wold like to help me. I need a function that takes
a list of 256 elements as an argument and returns the threshold values
for the threshold according to Otsu.

In addvance, I don't expect someone to do my homework. I really tried
it, I have been googling and didn't find a standalone function. I
wasn't able write a standalone function because I don't understand the
Otsu method. I just know that it works well and that I need it.

If there is no one that wants to help me with this problem, can
someone at least explain me in a detailed way how to implement it.

Thanks
 
H

Hyuga

Hy guys.
I'd like to ask you for a favour.
I tried several times to implement the otsu threshold filter in
python. but I failed every time. I found the soucre code i n Java from
the ImageJ project but I never worked in Java and there have been used
some built in Java functions which I don't know how they behave. I
also found the otsu threshold in the ia636 python module and would
like only this filter and don't want to import this library.
Is there anyone who wold like to help me. I need a function that takes
a list of 256 elements as an argument and returns the threshold values
for the threshold according to Otsu.

In addvance, I don't expect someone to do my homework. I really tried
it, I have been googling and didn't find a standalone function. I
wasn't able write a standalone function because I don't understand the
Otsu method. I just know that it works well and that I need it.

If there is no one that wants to help me with this problem, can
someone at least explain me in a detailed way how to implement it.

Thanks

What is the whole assignment meant to accomplish? Is the assignment
to implement the Otsu method? If so, you shouldn't be trying to find
library functions. Or is it just something you need for some larger
task?

I would ask exactly what problems you're running into, but:
it, I have been googling and didn't find a standalone function. I
wasn't able write a standalone function because I don't understand the
Otsu method. I just know that it works well and that I need it.

How do you know you need it? Did you learn about this in class? And
if so, are you expected to understand it?
I've never even heard of it, but I googled it, and found the fourth
hit pretty good: http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MORSE/threshold.pdf
This gives a reasonable explanation. I couldn't tell you *exactly*
why it works, but it's understandable enough from that that I can see
that it should work, and to see how to implement it.

Not to mention that the above PDF basically *gives* you the
implementation for free (just make sure not to miss the recurrence
relations at the end of the section on the Otsu method, or else you'll
be screwing yourself).

So give that a look and see if it helps.

Hyuga
 
A

azrael

the otsu filter is a filter that takes a image and from its histogram
calculates the values at which the image should be thresholded to
acomplish an optimal seperation of a foregtround and background
object.
I didn't hear about, but I used it through the ImageJ tool. It gave me
optimal results. I'm working on a project for my clases, and the last
thing I need to accomplish my goal is this filter. Is there anyone who
implemented it.

Thanks Hyuga
 
H

Hyuga

the otsu filter is a filter that takes a image and from its histogram
calculates the values at which the image should be thresholded to
acomplish an optimal seperation of a foregtround and background
object.

So I learned from the PDF I linked you to. Take a good look at it.
The equation is fairly simple to begin with, and the paper shows how
to simplify the calculation quite a bit.
Also, the Wikipedia article at http://en.wikipedia.org/wiki/Otsu's_method
even gives a simple pseudo-code implementation. I've tried it myself
in Python, and it seems give good results.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top