Doujinshi seem to represent usually works of amateurs, but that is a subjective measure. What is the objective difference between both works?
Doujinshi is closer to what we think of as "indie/self-published" comics compared to manga. Professionals can produce doujinshi as well as amateurs, and many mangaka will produce doujinshi on the side when they're otherwise unable to produce a certain work for legal reasons.
Doujinshi are often, but not limited to:
- Fanart of pre-existing intellectual properties
- Ecchi material
The quality of any given doujinshi can vary as a result, since literally anyone can produce a doujinshi without any sort of editorial oversight.
Well, if it's self published, it is called doujinshi. If it's by a manga publisher, it's manga. Note that this distinction makes no mention of relative quality...simply who is doing the publishing (and presumably paying for) the work.
Wikipedia highlights this in the first paragraph:
Dōjinshi (同人誌?, often transliterated as doujinshi) is the Japanese term for self-published works, usually magazines, manga or novels. Dōjinshi are often the work of amateurs, though some professional artists participate as a way to publish material outside the regular industry.
Note, professional artists can produce doujinshi if they're self-publishing that particular product.