Posterize based off of palette/image?

(pretty much asking for a plugin that does this) so basically select the parts that you want to posterize (snap to a color) and then in a area in the plugin you upload a image that contains a palette so it snaps all of the brick colors to the closest color of the pallete