You breached the lease when you painted the walls without your landlord’s permission. The landlord can withhold money from the security deposit. the amount the landlord can withhold is the reasonable cost of repainting the walls.
As a general rule, tenants are required to return the rental property to the landlord at the end of the lease in the same condition as when they entered into possession, normal wear and tear excepted. Normal wear and tear excepted means that wear and tear that would normally be expected to occur over the term of the lease.
While you may consider that painting the walls the colors that you likes amounted to an improvement of the property, even if it was an improvement, by painting the walls a different color, you are not returning the property in the same condition as you received it. Most landlords paint their houses in fairly neutral colors because neutral colors are more appealing to a wider range of prospective tenants and it is more economical to use fewer colors to paint their properties.