A project that I am working on requires some confidentiality and so I apologize in advance for any ambiguity regarding the question.

The project requires image processing, storage and retrieval from a database as well as some machine learning. I have written the code in Matlab but now I need to deploy it as a Web Service. My knowledge on Web Services is nil and I know nothing beyond creating a website and designing it with CSS.

For having a large database, I registered with the Amazon S3 which offers a great deal of control and storage space. I would greatly appreciate all the help I can get to achieve the following things:

1. I will have a webpage where the user uploads and image. I need to store the image in a database as well as do some image processing + machine learning.
2. After step 1, I need to return the processed image back to the user and save the results from the machine learning.

I saw that I can deploy Matlab code as a web service, however, I am a little unsure how well it would perform. Looks like Python with OpenCV might be a better option.

I am confused on the following things:

1. How will the website communicate back and forth with my main code?
2. How am I going to implement my main code with Amazon S3?
3. Would Python be the best language to write my main code on? In terms of efficiency, speed and connectivity with the website.
4. Lastly, a silly question: Where will my main code reside?

I would also like you to please keep in mind that later on, I would need to give up on Amazon S3 and have a custom server. Hence, I would not want to use services provided by Amazon to achieve my goal.

Thank you so much for all your help.