A high quality contribution but an annoying error is present in my published article I have recently published a journal article in the IEEE Transactions on Geoscience and Remote Sensing (IEEE TGRS). I can confirm that my contribution in the journal article is really of high quality and has promising results. Even my (very reputable) university congratulated me for my contribution during my PhD defense last year.

A few days ago, I discovered an error in my article. This error is really very annoying to me. In my article, I wrote:


  The database contains 200 images. We removed "23 images of type X", "32 images of type Y" and "12 images of type Z", and so as a result, we use 128 images.


And I mentioned "128" all the time in all my experiments.

That fact is that all my results are really based on the number "128". But if you look back, the total should be 200 - 67  = 133  not 128. So I missed to say in the journal that we have also removed "5 images of type A". In this case the total will really be 128 as I mentioned in all my experiments.  

All my results are correct and are really based on the number 128. But any reader can say "the total number of images must be 200 - 67 = 133 not 128, so how the author got 128!".

This is really awkward for me because I did this work in a very reputable university and I really wanted that everything to be perfect. I am really sad and I feel the failure and a bit like "Perhaps I don't deserve to be at this university".  What do you suggest me? should I contact the editor? Is it better to publish the correction online via ArXiv or HAL?
It is probably best to do all of that. Contact the editor and ask if a correction can be published (letters to editor, ...). Put out a corrected version somewhere visible. 

But also, don't obsess over it. Perfection is rarely attainable in an imperfect world with imperfect humans. 

The sort of error you mention is very common, actually. Once you write something it is difficult for you to read it as incorrect. Often your mind "reads" what you think is supposed to be on the page rather than what is actually there. It is notoriously difficult for people to proofread their own work. 

Ideally, the review process should have caught the inconsistency, but since it wasn't caught, others glossed over it also as immaterial to what your arguments are.