Skip to main content
12 events
when toggle format what by license comment
Aug 22, 2025 at 8:05 history bounty awarded CommunityBot
Aug 17, 2025 at 12:39 comment added Cris Luengo @indi Adding histograms is a common concept in the field of image processing. If a histogram is a summary representation of a set, then the sum of two histograms is the histogram of the set addition of the two sets they represent. Histogram subtraction would correspond to the set subtraction. There is no confusion to be had by overloading plus and minus for these operations.
Aug 17, 2025 at 12:37 comment added indi “It's a binary operation that has an identity element. It's associative and commutative.” The same is true for *, &, |, and ^. If that’s all it takes to justify using an operator, why not use & for integer addition? The answer is: because it ain’t addition. Period. You can play all the mental gymnastic games you want, but the bottom line is: it’s not “adding” two histograms, it’s merging their datasets, and + means “add”, not “merge”. This is not an operation that requires that level of brevity, and it doesn’t fit the definition of the operator, so using it is just plain wrong.
Aug 17, 2025 at 10:58 comment added Caleth @indi It's a binary operation that has an identity element. It's associative and commutative. It combines. If you accept + for monoids that aren't groups, it is acceptable. If you only accept + for groups, it isn't.
Aug 16, 2025 at 21:28 comment added indi The “adding” case where you can just add the bin values is really just a special-case optimization of the general case… which is clearly not “addition”. Nor is it concatenation (the other universally understood meaning of “+”). If any mathematical operator would apply, it would be “⋃”. But even that would be sketchy. When it’s this much of a stretch to justify an operator (even if it weren’t wrong), that’s a bad case for operator overloading.
Aug 16, 2025 at 21:28 comment added indi It wouldn’t be a good argument; “adding histograms” doesn’t really make sense. What would you expect to get? A histogram is a chart; is two histograms “added” a double chart of the two charts side-by-side? (📊+📊=📊📊?) No? You’d expect the two datasets to be merged (note: merged, not “added”)? And that’s “addition” because the bin data values are added? Except that’s wrong; the bin data values are only added in one specific case: when the bins of the two “operand” histograms are identical. Otherwise, the merge is done differently… not by addition, but by some kind of split-then-add.
Aug 16, 2025 at 14:47 comment added Caleth @indi I can see an argument for +, in the same sense as string concatenation might use +
Aug 16, 2025 at 9:40 vote accept JimmyHu
Aug 15, 2025 at 20:28 comment added indi I would say both operators (or all four, I guess) are an abuse of operator overloading. The idea of using histograms in equations is nonsense, as is the concept of “adding” histograms. I suppose histograms’ data can in some cases be “combined” or “merged”… though not added. But histograms themselves? Certainly not.
Aug 15, 2025 at 12:17 history edited Caleth CC BY-SA 4.0
added 4 characters in body
Aug 15, 2025 at 9:23 history edited Caleth CC BY-SA 4.0
added 906 characters in body
Aug 15, 2025 at 9:14 history answered Caleth CC BY-SA 4.0