Any existing java or matlab library to
- do image subtracting with background image
- clear out the shade
- do dilate and erode to count out how many person in a room?
Any existing java or matlab library to
OpenCV will help you do what you want, and there are Java bindings for it: Java OpenCV Bindings
In MATLAB you have the Image Processing Toolbox.
Matlab has just the toolbox for this purpose. I'd highly recommend viewing Matlab's video processing webinar. There are examples of object counting:
It might be a perfect fit for you.