In a former life I did software for Digital Signal Processing. Reading this Wikipedia page on JPEG reminded me of old headaches.
Changes really are applied across the image. Here is one paragraph of many.
This is a picture I'll use for a demo. It has been processed already but it really doesn't matter. This is the starting jpeg of a local restaurant with a neat paint and lighting scheme.Color space transformation
First, the image should be converted from RGB into a different color space called Y′CBCR (or, informally, YCbCr). It has three components Y', CB and CR: the Y' component represents the brightness of a pixel, and the CB and CR components represent the chrominance (split into blue and red components). This is basically the same color space as used by digital color television as well as digital video including video DVDs, and is similar to the way color is represented in analog PAL video and MAC (but not by analog NTSC, which uses the YIQ color space). The Y′CBCR color space conversion allows greater compression without a significant effect on perceptual image quality (or greater perceptual image quality for the same compression). The compression is more efficient because the brightness information, which is more important to the eventual perceptual quality of the image, is confined to a single channel. This more closely corresponds to the perception of color in the human visual system. The color transformation also improves compression by statistical decorrelation.
Capture NX shows me that the three lights and TV screen over the bar all present as 255,255,255 basically pure white. If I make one of those my 'black' spot the entire image turns black. There is no detail anywhere, just black so I won't show that one.
Now,the wall to the right of the TV between the lights presents as orange which would be some mix of Red and Green. If I call that Black look what happens.
The major impact is on the green channel which practically disappears except for a bit on the left side. The orange of the lights to the left of the TV becames very very red.
Now, let's take a primarily Red area. In this case on the left side of the bar is a set of shelves with wine bottles. The center one is empty and the right side presents as a shade of red. If I make that the 'black' spot this is what I get.
There is still a bit of red left but all that orange and yellow has become very green.
The paragraph I quoted above is basically how luminance is covered and the wiki article explains it in more detail than I want to know. The Wiki is a good general description. The real challenge in developing this sort of software is dealing with all the various manifestations of information from internal storage to hologram to hardcopy. I am happy to be retired now long enough that the technology has changed enough that nobody wants me back