A computer-implemented method for processing an image comprising dendritic spines, the method comprising the steps of obtaining the image comprising at least one dendritic spine (110), obtaining the coordinates of the tip point (311) and the base point (312), detecting the skeleton (317) of the dendritic spine (110) by analyzing the brightness of consecutive image portions (316) arranged perpendicularly to an axis extending through the tip point (311) and the base point (312) and for each image portion (316) selecting the brightest point distanced not more than a predefined threshold (s) from the brightest point (314) of the previous image portion (316), detecting the contour (319) of the dendritic spine (310) by analyzing the brightness of consecutive image portions (318) arranged perpendicularly to the skeleton (317) and selecting the contour points (320) as points at which the plot brightness of the image portion transits the point having the brightness lower than the brightness (B) of the skeleton point multiplied by a brightness factor (η) at a furthest distance from the skeleton (317).