# Rosetta Code Task "Percentage difference between images" what is "Luminance"?

**URL:** <https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785>\
**Category:** General\
**Created:** [April 18, 2024, 5:52pm UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785 "2024-04-18T17:52:50Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ret\_Build\_Engineer](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/ccd318/32.png) [@Ret\_Build\_Engineer](https://forum.ada-lang.io/u/Ret_Build_Engineer)\
**Post date:** [April 18, 2024, 5:52pm UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/1 "2024-04-18T17:52:51Z")

</div>

Hi;

Another Ada question sparked (no pun intended) by a Rosetta Code Task.

What is “Luminance”?

This is found on two (more?) Rosetta Code Tasks and I don’t think that this is “native” Ada, it must come from an external package which is not noted or specified.

> **[Percentage difference between images - Rosetta Code](https://rosettacode.org/wiki/Percentage_difference_between_images#Ada)**

Thanks,  
Retired Build Engineer

---

<div class="post-metadata">

**Author:** ![flexibeast](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/flexibeast/32/399_2.png) [@flexibeast](https://forum.ada-lang.io/u/flexibeast)\
**Post date:** [April 19, 2024, 2:21am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/2 "2024-04-19T02:21:19Z")

</div>

‘Luminance’ is not an Ada-specific thing; it basically means ‘brightness’. Here’s the relevant [Wikipedia article](https://en.wikipedia.org/wiki/Luminance):

> **Luminance** is a photometric measure of the luminous intensity per unit area of light travelling in a given direction. It describes the amount of light that passes through, is emitted from, or is reflected from a particular area, and falls within a given solid angle.

So the Rosetta code assumes one has elsewhere defined a scalar `Luminance` type, in the same way that some other example might assume that one has elsewhere defined e.g. a `Mass` type without explicitly specifying that type within the example.

That said, my feeling is that it would probably be better for Rosetta code examples to be as self-contained as possible, so that they can be directly tested “out of the box”.

---

<div class="post-metadata">

**Author:** ![Ret\_Build\_Engineer](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/ccd318/32.png) [@Ret\_Build\_Engineer](https://forum.ada-lang.io/u/Ret_Build_Engineer)\
**Post date:** [April 19, 2024, 3:50am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/3 "2024-04-19T03:50:14Z")

</div>

Thanks for your response. I felt that this Rosetta Code Task written in Ada was not really helpful. I have looked for Ada packages that “might” be appicable, and was not really satisfied with the results, not enough to proceed with my investigation further without some external guidance. I was vaguely familar with “Luminance” in a scientific concept, but was hoping somebody would be able to make the connection to this Ada code.

Retired Build Engineer

---

<div class="post-metadata">

**Author:** ![DelusionalMuppet](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/delusionalmuppet/32/392_2.png) [@DelusionalMuppet](https://forum.ada-lang.io/u/DelusionalMuppet)\
**Post date:** [April 19, 2024, 4:50am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/4 "2024-04-19T04:50:13Z")

</div>

The package Bitmap\_Store defined in [this task](https://rosettacode.org/wiki/Bitmap#Ada) does have Luminance type definition. That solution in the percentage difference use the bitmap comparison, the alternative task definition.

As you can see the Ada solution of percentage difference between images is only code snippet, not the complete procedure, hence it omits the with clause etc.

---

<div class="post-metadata">

**Author:** ![Ret\_Build\_Engineer](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/ccd318/32.png) [@Ret\_Build\_Engineer](https://forum.ada-lang.io/u/Ret_Build_Engineer)\
**Post date:** [April 19, 2024, 5:32am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/5 "2024-04-19T05:32:57Z")

</div>

Thank you for your reply. This info definitely helps. It would be nice if a reference was made in the Rosetta Code Task in question to the Rosetta Code task with the definition. I don’t have to have complete code, snippets are fine, but I didn’t know where to look for the missing pieces. And even if I did, I wouldn’t be sure that what I found was pertinent.

Retired Build Egineer

---

<div class="post-metadata">

**Author:** ![flexibeast](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/flexibeast/32/399_2.png) [@flexibeast](https://forum.ada-lang.io/u/flexibeast)\
**Post date:** [April 19, 2024, 5:38am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/6 "2024-04-19T05:38:08Z")

</div>

Because beginners are, well, beginners, it’s not necessarily going to be ‘obvious’ which things are built-in to a language, which things require use of ‘batteries’ (i.e. standard libraries) that might be provided (which in the case of Ada, differs depending on which implementation is being used), and which things will need to be provided by some other means (e.g. via a library that’s available, via the user writing it themselves, etc.).

In this particular case, there’s no indication in the “Ada” section of the “Percentage difference between images” page that the “Bitmap” page provides an appropriate definition of the `Luminance` type; and i don’t feel it’s ‘obvious’ to look for such a page to find such a definition.

Personally, i’ve rarely found Rosetta Code particularly helpful for learning a language, as overall as it feels like something to:

- give people a rough idea of what it’s like to use a language[a]; and
- provide a ‘cookbook’ for intermediate-level users who are basically familiar with a language in general, but want to quickly get a sense of how to implement something in an area they have little to no experience in.

[a] Hence so many ‘[programming tasks](https://rosettacode.org/wiki/Category:Programming_Tasks)’ about number theory, such as ‘[disarium numbers](https://rosettacode.org/wiki/Disarium_numbers)’ ([OEIS A032799](https://oeis.org/A032799)), and the ‘[Solutions by Programming Task](https://rosettacode.org/wiki/Category:Solutions_by_Programming_Task)’ page listing page counts like:

- Games (57 P)
- Puzzles (49 P)

but

- Database operations (4 P)
- Flow control (empty)
- Memory management (2 P)
- Streams (2 P)

---

<div class="post-metadata">

**Author:** ![simonjwright](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/simonjwright/32/11_2.png) [@simonjwright](https://forum.ada-lang.io/u/simonjwright)\
**Post date:** [April 19, 2024, 7:52am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/7 "2024-04-19T07:52:24Z")

</div>

Rosetta on Flow Control has an Ada section covering goto and loop exit.

What’s missing is early `return` from procedures (I just re-set my account, so will add if moved to do so!)

You might have expected exceptions, but there’s an Ada section in Exceptions already. And see discussion on the Flow Control page.

---

<div class="post-metadata">

**Author:** ![flexibeast](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/flexibeast/32/399_2.png) [@flexibeast](https://forum.ada-lang.io/u/flexibeast)\
**Post date:** [April 19, 2024, 9:49am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/8 "2024-04-19T09:49:09Z")

</div>

Ah! So the issue isn’t that flow-control-related examples don’t exist, it’s just that they’ve not been added to the ‘Flow control’ category, such that they’re not discoverable via that category link on the ‘Solutions by Programming Task’ page. Thanks for the heads-up!

i wasn’t expecting a specific thing, such as exceptions; my point was to note that someone coming to the ‘Solutions by Programming Task’ page would be presented with information suggesting that there were _no_ pages dealing with flow control, yet 49 pages dealing with solutions to programming puzzles.

Well, i’ll create an RC account, and try to make some improvements in this regard …

---

<div class="post-metadata">

**Author:** ![flexibeast](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/flexibeast/32/399_2.png) [@flexibeast](https://forum.ada-lang.io/u/flexibeast)\
**Post date:** [April 19, 2024, 10:21am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/9 "2024-04-19T10:21:30Z")

</div>

i’ve just created my account and done some edits.

As a result, where the non-language-specific ‘[Solutions by Programming Task](https://rosettacode.org/wiki/Category:Solutions_by_Programming_Task)’ page used to state “Flow control (empty)”, as i described above, it now states “Flow control (1 C, 3 P)”, indicating that the “Flow control” category contains one (sub)category and three pages; and if one clicks on that link, one is taken to the “[Category:Flow control](https://rosettacode.org/wiki/Category:Flow_control)” page, which now contains links to that subcategory and three pages: “Iteration (25 P)”, “Conditional structures”, “Exceptions”, and “Flow-control structures”.

(The contents of those two pages are automatically generated, so one can’t access their content prior to [the edits i made](https://rosettacode.org/wiki/Special:Contributions/Flexibeast), which simply added “[[Category:Flow control]]” to four pages.)

So the issue here wasn’t anything to do with the Ada examples in particular; it was an issue with Rosetta Code pages more generally.

---

<div class="post-metadata">

**Author:** ![DrPi](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/drpi/32/225_2.png) [@DrPi](https://forum.ada-lang.io/u/DrPi)\
**Post date:** [April 19, 2024, 12:53pm UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/10 "2024-04-19T12:53:46Z")

</div>

You can also fix the `function "-" (Left, Right : Pixel) return Count` function which contains `(Left.G - Left.G)` in the computation.

---

<div class="post-metadata">

**Author:** ![flexibeast](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/flexibeast/32/399_2.png) [@flexibeast](https://forum.ada-lang.io/u/flexibeast)\
**Post date:** [April 20, 2024, 1:23am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/11 "2024-04-20T01:23:12Z")

</div>

> You can also fix the `function "-" (Left, Right : Pixel) return Count` function which contains `(Left.G - Left.G)` in the computation.

i presume it should say `(Left.G - Right.G)`, so i’ve just made that edit.

However, as a general point, and speaking as someone who’s a beginner to Ada, i would like to ask those who notice clear code errors in the Ada examples on Rosetta Code to please [create an account](https://rosettacode.org/wiki/Special:CreateAccount) and make such edits themselves. It only takes a minute or so to create an account, and i already have a lot of things on plate: in addition to my ongoing work on the Gentoo wiki, and maintaining my man page ports of documentation for software in the s6 ecosystem, i’m also in the middle of trying to resolve some encoding issues a user is having with my Ebuku package for Emacs, all in the context of me trying to support two disabled loved ones whilst having chronic health issues myself.

i’m certainly happy to try to make documentation improvements as i notice them and am reasonably confident of what needs to change, but at this point i don’t have the capacity to become an implementor of others’ suggested changes.

---

<div class="post-metadata">

**Author:** ![Ret\_Build\_Engineer](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/ccd318/32.png) [@Ret\_Build\_Engineer](https://forum.ada-lang.io/u/Ret_Build_Engineer)\
**Post date:** [April 20, 2024, 2:15am UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/12 "2024-04-20T02:15:11Z")

</div>

I appreciate the positive impact you have made here.

Retired Build Engineer.

---

<div class="post-metadata">

**Author:** ![JC001](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@JC001](https://forum.ada-lang.io/u/JC001)\
**Post date:** [April 20, 2024, 6:24pm UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/13 "2024-04-20T18:24:12Z")

</div>

In image processing, luminance is a shade of gray that represents the perceived lightness of a color. A luminance image is often a better grayscale version of a color image than other techniques, such as HSV Value, HSL Lightness, or average of RGB.

As a data type, Luminance would usually be the representation of a grayscale pixel, typically `mod 256`, though it can also be represented by a floating-point value in `0.0 .. 1.0`.

---

<div class="post-metadata">

**Author:** ![DrPi](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/drpi/32/225_2.png) [@DrPi](https://forum.ada-lang.io/u/DrPi)\
**Post date:** [April 20, 2024, 9:47pm UTC](https://forum.ada-lang.io/t/rosetta-code-task-percentage-difference-between-images-what-is-luminance/785/14 "2024-04-20T21:47:48Z")

</div>

One can add that the luminance appeared with old analog color TV systems (PAL, SECAM, NTSC). Before color systems, black and white systems where used. When color systems appeared, they had to be compatible with the black and white systems. So, the luminance (Y) was the equivalent of the black and white signal and was transmitted in a compatible way. The color information (the chrominance : Cr, Cb) was transmitted in “parallel” (to simplify) to the luminance. A black and white TV receiver was able to receive a color signal but displayed only the luminance information (a black and white image) while a color TV receiver was able to decode the full signal and display a color image.
