Warning, always convert your colors to from sRGB to Linear RGB before doing any math on them, then convert them back to sRGB afterwards for displaying them.
sRGB is the familiar color space you all know and love, it's what your display uses, and it's what has those RGB numbers between 0 and 255. But it's not a linear color space.
First think of values as being between 0 and 1 instead of 0 and 255. To change sRGB to Linear, do X^2.2 (close to squaring the value). To change Linear back to sRGB, do X^(1/2.2) (close to a square root).
In Linear RGB, a value of 0.5 is halfway between black and white. You can put a stripe or checkerboard pattern next to the color value, and it will appear to be the same brightness. But in sRGB, a value of 0.5 is much darker. Linear RGB of 0.5 is roughly equivalent to sRGB of 0.73.
The actual method of conversion involves a complicated curve that isn't continuous, using X^2.2 is still an approximation.
>First, the average pixel is not what I would expect it to be at all
It looks like the averaging was done in default sRGB color space, with:
magick "$f" -resize 1x1 txt:-
Downscaling should instead be done in a linear colorspace. Human vision is non-linear, but the filtering required for downscaling is equivalent to blurring, which is linear because it's done optically not within the retina or brain. Using ImageMagick:
Additionally, JPEG supports chroma subsampling, which is usually enabled by default. I don't know what sips does, but with these small files you might as well use PNG and avoid the risk of losing color information this way.
This should produce results closer to human perception.
The average pixel doesn't look correct because human vision does not interepret shadowed colors as different colors. We first guess at the shadows, and then do some kind of inverse mapping from the shaded color space to the illuminated one before we "perceive a color". This is why the black,blue/white,gold dress illusion exists.
I'm of the belief that fruit and vegetable packaging is often designed to hide defects, and to make it harder to visually discern how fresh the produce is (on top of not letting you touch it).
Some examples.
Red netting on oranges makes it hard to see imperfections on the skin. Green netting does the same for avocados. Costco sells corn in trays that are cling wrapped with a wrap that is unmistakably designed to hide the ends of the corn (the easiest way to discern if corn has gone bad). Other fruits, and veggies like melons, onions, and potatoes have similar netting with colors that seem to be carefully chosen to maximize visual clutter.
Why aren't all the nets the same color?
Costco sometimes sells pears in plastic trays with multiple creases that cause reflections that make it very difficult to see what the pears inside look like.
Supermarkets also sometimes play with the light around the vegetables. Some areas have so much red in the light that you better take the items to a different area to be able to see if they are yellow or orange.
Taking another look, I think you're right! Particularly since the first orange is pretty orange already. I think the first example would have been better served with a yellower, less ripe orange to highlight the difference and the pull in the redder, riper direction from the bag.
Colours are often very relative though. We usually don't see a single orange on a white background. I'm not sure that would be representitive of real oranges at the shopping mall.
Also that picture (both versions) are the brownish oranges i have ever seen in my life.
It makes sense that adding red adds red (in addition to the avocado sacks you mention, I think of lemons’ yellow bags, limes’ green bags, and the red packaging/shelf lining and pink-tinged light in the butcher’s case)—but those images really do look strangely exposed to me.
Did you do exercise any specific control over the phone’s camera?
I wonder if the ring light might use the sort of general-market LEDs that underperform specifically at illuminating saturated reds and oranges in this range… see for example
That's a good question, and I could easily see the camera settings (and the light) being a source of error here. Naively, I used the default iPhone camera with the same exposure for each one, then ended up manually removing some of the HDR settings from each one when they were showing up as way overexposed on my computer. Not exactly an advanced, scientific technique, and there was also a bright source of soft white light from the window next to the setup, which could have thrown off the automatic exposure.
Another comment mentioned it, but I wonder if the overall effect would be more visible with yellower baseline oranges (or, as you mention, pale lemons and limes). Really interesting about the LEDs underperforming as well!
This was my immediate thought when I saw the ring light. Very very likely a CRI of 90 or below, which doesn’t even weight much in red shades. Not uncommon to see 92 CRI with a R9 (red) score below 50% of sunlight or tungsten illumination.
This is one of those things I knew on some subconscious level but never really thought about until now. Of course the red mesh makes them look more orange - it's basically grocery store color grading. Honestly kinda love how simple the trick is. No fancy tech, no marketing wizardry - just "put red stuff over orange stuff, profit." Makes me wonder what other dumb little visual hacks are happening around me that I'm not noticing at all.
I think the lighting/camera work doesn't help here. The first photo of the orange...doesn't look orange. It's really dark. In the photo from the shop they look orange.
Am i mossing something or is this really a blog post saying that if you put something red in a picture and compare it to the same thing without red, then the picture with more red, looks, well, more red?
If you put an object of color X of intensityn N in a net with color X of intensity N+M, then the object will get some spill over from the net similar to M, which the brain/person doesn't necessarily realise and simply assigns it to the object ad well.
It is also a consumer advice about not comparing an orange inside a bag (of any color) with one outside of one as we have a hard time truly comparing them.
In response to the observation the average pixel color is surprisingly brown, I'll take today's opportunity to induct some of my fellow HNers into today's lucky 10,000 by linking Technology Connections's "Color is weird" video (https://www.youtube.com/watch?v=wh4aWZRtTwU).
Thank you for the video, that was really interesting. I had no idea that brown was orange, and that makes me wonder how those darker colors are perceived by people with many more categories of colors in their minds. If simply naming brown makes it seem like a unique color, I imagine the abrupt switchover that I experienced watching that video would happen for more color-discerning people as well when they see "Dark Blue" or "Dark Purple" or "Dark Red".
Or... maybe you have be both discerning and naive in regards to it for the illusion to work.
The best oranges [0] I've had were half green. Fresh from the tree, but still plenty ripe.
It's my understanding that oranges for transport to colder countries are picked unripe and ripened in the holds of cargo ships. This ripening process is great at making the skin more orange, and OK at improving the flavour, but nowhere near as good for that as ripening on the tree.
So if I saw green patches on my supermarket oranges, far from the tropics, I'd be conditioned to expect them to be really good. They wouldn't be, of course.
[0] Satsumas? Clementines? I don't want to get into a debate about what taxonomically is an orange, but these were citrus fruit that turn orange in colour when ripe.
How green an orange is when ripe has to do with the climate they are grown in. In warm climates with little variation in temperature between day or night, oranges will remain green on the tree even when ripe. If nights get cold enough (~55 F), they will turn orange.
That said, in the US, oranges destined for markets de-greened for aesthetic purposes since customers won't generally buy them otherwise.
Some oranges, especially the ones you find in Asia or at Asian fruit stands, can be completely ripe and still completely green. The ones sold in US stores are almost all sour and unripe if they are green (almost always but not always). Different regions in the world 'know about' different citrus fruit (there seem to be a lot of overlap and a lot of non-overlap with fruit), so your mileage may vary. Reddit claims this is because of the temperatures: https://www.reddit.com/r/VietNam/comments/16ca895/why_are_th... It's fun to go to fruit stands when traveling and try the fruits you don't recognize! Lots of fruits are very different if you travel to countries where they can grow them natively, and there are a lot of tropical fruits that aren't exported. Lots of the English words for fruits are re-used so you can be eating something totally unrecognized and it's a "tree cherry" or something.
For example, what they call a lime in a lot of countries (for example Calamansi) would be called a tiny orange in North America (we don't have that fruit here). What we call a lime they wouldn't recognize, but if they saw/tasted it they might think it's a green lemon or something.
Oranges and other citrus are examples of non-climacteric fruits, meaning they do not continue to ripen after being picked. So, they have to be picked at the desired level of ripeness.
The best-tasting oranges looked nothing like the perfectly polished, all-orange supermarket ones. Some of them were downright ugly by grocery store standards
I think the author is on the right track just needs to refine the assumptions a bit. Not sure if the method actually tests whether we perceive the oranges as more orange with red bags. Things like too small of a sample size, lack of any statistical analysis, uncontrolled lighting conditions, not controlling for phone camera, and simplistic color analysis (human eye is much more complex). Also lack of applicability to color science principles
The oranges he used were very ripe. Lately small oranges like tangerines have been very ripe for me. Sometimes when they are out of season they are borderline green, or actually have visible green on them, or are basically yellow. When they are so unripe, the red/orange bag makes a HUGE difference in how they look, it's night and day.
Not a typical orange. “Sumo Citrus” / dekopon / shiranui is a hybrid tangor/tangerine cross. Very fragile, specialty fruit, only recently available at scale in the eastern US. This is on the high end per-fruit but I’ve seen higher. I usually buy in cases at ~$1.25 per fruit.
Funny experiment however you can change outcome of it just by changing white balance on the camera. I'm not sure if the creator is aware of that the camera in his phone is always choosing the white balance, and that he should setup manual mode and have constant light source for this to compare.
I don't think averaging the color over the whole image is the right way to do this. When you buy bagged oranges you pick up a bag and look at it close, not squint at it from a distance.
OT Q: What are the mesh bags made of? They always leave a detritus of orange (citrus) or green (avocados) on the counter; we're definitely ingesting this stuff.
This is interesting because it shows us how a programmer thinks of a problem vs. how a psychologist or neuroscientist would think of this problem and highlights the lack of "human-ness" in programmer thinking.
I'm no fan of schools forcing STEM students to study boring electives but this is a prime example of why that might be useful.
The entire premise of the post is wrong - average pixel value has nothing to do with how orange the oranges look - it's all about perception.
You saw someone making a bunch of observations, setting up an experiment and trying to use maths/programming to prove an hypothesis they believed to be a sign of "lack of human-ness"?
To me it showed curiosity and ingenuity, sure they might not have studied a certain subject but it is a totally valid approach to an unknown problem. It might actually get people who have similar "silly questions" to run a similar set of experiment and perhaps stumble upon something novel.
You comment showed less human-ness than OP, ironically.
While you are correct about color perception, I don't see the link to a 'lack of humanness in programmer thinking'. It's not an inherent trait to software engineers. The entire field of HCI, interaction design and everything around how we deal with digital colors are fully focused on the human experience.
Maybe a reminder that computer science != programming.
It's not a "programmer" problem. Any competent program I know would never thing of averaging the color of the orange with the color of the non-orabge bag, and expect that to be orange, or representative of how we percieve the orange.
Dwedit|10 months ago
sRGB is the familiar color space you all know and love, it's what your display uses, and it's what has those RGB numbers between 0 and 255. But it's not a linear color space.
First think of values as being between 0 and 1 instead of 0 and 255. To change sRGB to Linear, do X^2.2 (close to squaring the value). To change Linear back to sRGB, do X^(1/2.2) (close to a square root).
In Linear RGB, a value of 0.5 is halfway between black and white. You can put a stripe or checkerboard pattern next to the color value, and it will appear to be the same brightness. But in sRGB, a value of 0.5 is much darker. Linear RGB of 0.5 is roughly equivalent to sRGB of 0.73.
The actual method of conversion involves a complicated curve that isn't continuous, using X^2.2 is still an approximation.
brookst|10 months ago
mcherm|10 months ago
Isn't continuous? Really? That seems surprising to me; tell me more.
mrob|10 months ago
It looks like the averaging was done in default sRGB color space, with:
magick "$f" -resize 1x1 txt:-
Downscaling should instead be done in a linear colorspace. Human vision is non-linear, but the filtering required for downscaling is equivalent to blurring, which is linear because it's done optically not within the retina or brain. Using ImageMagick:
magick "$f" -colorspace RGB -resize 1x1 -colorspace sRGB txt:-
Additionally, JPEG supports chroma subsampling, which is usually enabled by default. I don't know what sips does, but with these small files you might as well use PNG and avoid the risk of losing color information this way.
This should produce results closer to human perception.
noqc|10 months ago
The average pixel doesn't look correct because human vision does not interepret shadowed colors as different colors. We first guess at the shadows, and then do some kind of inverse mapping from the shaded color space to the illuminated one before we "perceive a color". This is why the black,blue/white,gold dress illusion exists.
RataNova|10 months ago
ipv6ipv4|10 months ago
Some examples.
Red netting on oranges makes it hard to see imperfections on the skin. Green netting does the same for avocados. Costco sells corn in trays that are cling wrapped with a wrap that is unmistakably designed to hide the ends of the corn (the easiest way to discern if corn has gone bad). Other fruits, and veggies like melons, onions, and potatoes have similar netting with colors that seem to be carefully chosen to maximize visual clutter.
Why aren't all the nets the same color?
Costco sometimes sells pears in plastic trays with multiple creases that cause reflections that make it very difficult to see what the pears inside look like.
adornKey|10 months ago
pixelatedindex|10 months ago
horsawlarway|10 months ago
The unbagged oranges are more appealing.
otras|10 months ago
happymellon|10 months ago
We know that other people will not be truthful, misleading even.
We subconsciously know that the bag is orange to manipulate us.
Could it look better because you know it's truthful?
bawolff|10 months ago
Also that picture (both versions) are the brownish oranges i have ever seen in my life.
RataNova|10 months ago
alwa|10 months ago
Did you do exercise any specific control over the phone’s camera?
I wonder if the ring light might use the sort of general-market LEDs that underperform specifically at illuminating saturated reds and oranges in this range… see for example
https://www.canada.ca/en/conservation-institute/services/con...
and
https://indiecinemaacademy.com/are-leds-ruining-your-project...
otras|10 months ago
Another comment mentioned it, but I wonder if the overall effect would be more visible with yellower baseline oranges (or, as you mention, pale lemons and limes). Really interesting about the LEDs underperforming as well!
johncalvinyoung|10 months ago
RataNova|10 months ago
rightbyte|10 months ago
Maybe tomatoes are in boxes that make them look more red? Who knows. I am looking forward to the next super market visit.
dylan604|10 months ago
If it's marketing, all of it. Movies as well.
basisword|10 months ago
ricardobeat|10 months ago
pezezin|10 months ago
jaffa2|10 months ago
xandrius|10 months ago
It is also a consumer advice about not comparing an orange inside a bag (of any color) with one outside of one as we have a hard time truly comparing them.
RataNova|10 months ago
JadeNB|10 months ago
Syntonicles|10 months ago
Or... maybe you have be both discerning and naive in regards to it for the illusion to work.
krisoft|10 months ago
NicOnHN|10 months ago
They are SUMOs which belong to the Dekopon crop type.
rf15|10 months ago
jader201|10 months ago
If you look at the pic below where it shows the oranges in the store, they’re much oranger.
For a post about color accuracy, it seems odd the comparison pics seem to have some color imbalance to them.
dmurray|10 months ago
It's my understanding that oranges for transport to colder countries are picked unripe and ripened in the holds of cargo ships. This ripening process is great at making the skin more orange, and OK at improving the flavour, but nowhere near as good for that as ripening on the tree.
So if I saw green patches on my supermarket oranges, far from the tropics, I'd be conditioned to expect them to be really good. They wouldn't be, of course.
[0] Satsumas? Clementines? I don't want to get into a debate about what taxonomically is an orange, but these were citrus fruit that turn orange in colour when ripe.
Aloisius|10 months ago
That said, in the US, oranges destined for markets de-greened for aesthetic purposes since customers won't generally buy them otherwise.
ltbarcly3|10 months ago
For example, what they call a lime in a lot of countries (for example Calamansi) would be called a tiny orange in North America (we don't have that fruit here). What we call a lime they wouldn't recognize, but if they saw/tasted it they might think it's a green lemon or something.
Clamchop|10 months ago
RataNova|10 months ago
Morizero|10 months ago
There's already so much food waste due to safe but blemished produce though!
firesteelrain|10 months ago
motoxpro|10 months ago
ltbarcly3|10 months ago
ThePowerOfFuet|10 months ago
johncalvinyoung|10 months ago
seszett|10 months ago
qwertyu3|10 months ago
[deleted]
p0w3n3d|10 months ago
pier25|10 months ago
https://en.wikipedia.org/wiki/Complementary_colors
lupusreal|10 months ago
dowager_dan99|10 months ago
bell-cot|10 months ago
pikuseru|10 months ago
unknown|10 months ago
[deleted]
xyzal|10 months ago
ncr100|10 months ago
3l3ktr4|10 months ago
thousand_nights|10 months ago
artimaeis|10 months ago
https://en.m.wikipedia.org/wiki/Dekopon
decimalenough|10 months ago
Fun fact: "dekopon" means basically "outie" (as in protruding navel, not Severance).
ncr100|10 months ago
They are just excited to see you, too.
djaouen|10 months ago
windsignaling|10 months ago
I'm no fan of schools forcing STEM students to study boring electives but this is a prime example of why that might be useful.
The entire premise of the post is wrong - average pixel value has nothing to do with how orange the oranges look - it's all about perception.
Here's an example where the same exact color (pixel value) can be perceived as either light or dark depending on the context: http://brainden.com/images/identical-colors-big.jpg
That's what the bag adds - context - but the author hasn't made this connection.
xandrius|10 months ago
To me it showed curiosity and ingenuity, sure they might not have studied a certain subject but it is a totally valid approach to an unknown problem. It might actually get people who have similar "silly questions" to run a similar set of experiment and perhaps stumble upon something novel.
You comment showed less human-ness than OP, ironically.
ricardobeat|10 months ago
Maybe a reminder that computer science != programming.
AndrewDucker|10 months ago
But so does its colour.
So observing how a red mesh affects that colour is absolutely worth investigating.
BostonFern|10 months ago
hyperhopper|10 months ago
dang|10 months ago
It's all too easy to come across as supercilious and I'm afraid you crossed the line, no doubt inadvertently.
https://news.ycombinator.com/newsguidelines.html
amarshall|10 months ago
aaron695|10 months ago
[deleted]
VeninVidiaVicii|10 months ago
gherkinnn|10 months ago
vultour|10 months ago
dyauspitr|10 months ago
unknown|10 months ago
[deleted]