Don't release main image
Factor threshold calculation to seperate method
Move debugging square into clup method
Don't release main image