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


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.

Retired Build Engineer

‘Luminance’ is not an Ada-specific thing; it basically means ‘brightness’. Here’s the relevant Wikipedia article:

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”.

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

The package Bitmap_Store defined in this task 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.

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

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’ about number theory, such as ‘disarium numbers’ (OEIS A032799), and the ‘Solutions by Programming Task’ page listing page counts like:

  • Games (57 P)
  • Puzzles (49 P)


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

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.

1 Like

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 …

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

As a result, where the non-language-specific ‘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” 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, 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.

1 Like

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

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 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.

I appreciate the positive impact you have made here.

Retired Build Engineer.

1 Like

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.

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.