Placing color boxes on a colored image such that color consistency is maximized
Just an extended note to show that the decision version of your problem ("Is there a placement of the bounding boxes such that $n_{good} - n_{bad} \geq k$?" ) is NP-complete even for two colors $C = \{c_1, c_2\}$ and two bounding boxes $B_1 \equiv \langle col=c_1, w=3, h=1 \rangle$, $B_2 \equiv \langle col=c_2, w=1, h=1 \rangle$.

The reduction is straightforward from: Danièle Beauquier, Maurice Nivat, Eric Rémila, Mike Robson: Tiling Figures of the Plane with Two Bars. Comput. Geom. 5: 1-25 (1995) 

They prove that tiling a figure on the plane grid with two horizontal/vertical bars with length at least 3 is NP-complete.

The reduction to your problem is simple: just color the "pixels" of the figure with color $c_1$ and fill the remaining background pixels of the $N+1\times N+1$ square region around it with color $c_2$. You can place the bounding boxes $B_1, B_2$ with $n_{good} - n_{bad} = (N+1)^2$ if and only if the original figure is tileable with $3 \times 1$ horizontal/vertical bars.