I also think it's the 'feels' of a place that may give it an impression worse than it is.
When I was in Genoa certain areas of the labyrinthine, medieval Old City was warned to me as dangerous, including my airbnb host:
At ground level, interspersed with the gorgeous streets and piazzas, palaces and churches, some alleys looked naturally eerie if devoid of streetlife,
as the buildings were so close and the sun blocked. At night even worse:
However, there was one area of absolutely dodge that I exited quickly every time I came across it -prostitutes, open drug taking, a cloud of weed and music blaring. Only the poorest, lounging around.
Later on -introduced by a friend -I realised it also held the best bars in town, and ended up there almost every night. Never had an issue or saw any transgressions through every night, for hours.
It was of course a big hangout for the 'creative class' and students, and I'd drink on the steps of the nearby church and watch the street theatre.
In reality the crime rate was likely much lower than the grand streets of Westminster or The City, just the optics didn't look good.